95 lines
2.7 KiB
JavaScript
95 lines
2.7 KiB
JavaScript
describe('The Login Page', () => {
|
|
it('login and redirect to main page', () => {
|
|
const username = 'test';
|
|
const password = 'test';
|
|
|
|
cy.visit('/');
|
|
cy.login(username, password, true);
|
|
cy.get('body').contains('Neues Wissen erwerben');
|
|
});
|
|
|
|
it('user sees error message if username is omitted', () => {
|
|
const username = '';
|
|
const password = 'test';
|
|
|
|
cy.visit('/');
|
|
cy.login(username, password);
|
|
cy.get('[data-cy=email-local-errors]').contains('ist ein Pflichtfeld');
|
|
});
|
|
|
|
it('user sees error message if password is omitted', () => {
|
|
const username = 'test';
|
|
const password = '';
|
|
|
|
cy.visit('/');
|
|
cy.login(username, password);
|
|
cy.get('[data-cy=password-local-errors]').contains('ist ein Pflichtfeld');
|
|
});
|
|
|
|
it('user sees error message if credentials are invalid', () => {
|
|
const username = 'test';
|
|
const password = '12345';
|
|
|
|
cy.visit('/');
|
|
cy.login(username, password);
|
|
cy.get('[data-cy=login-error]').contains('Die E-Mail oder das Passwort ist falsch. Bitte versuchen Sie nochmals.');
|
|
});
|
|
|
|
it('redirect after login', () => {
|
|
const username = 'test';
|
|
const password = 'test';
|
|
|
|
cy.visit('/book/topic/berufliche-grundbildung');
|
|
cy.login(username, password);
|
|
cy.get('body').contains('Berufliche Grundbildung');
|
|
});
|
|
// it('logs in programmatically without using the UI', () => {
|
|
// cy.visit('/accounts/login/'); // have to get a csrf token by getting the base page first
|
|
//
|
|
// const username = 'test';
|
|
// const password = 'test';
|
|
//
|
|
// cy.getCookie('csrftoken').then(token => {
|
|
// const options = {
|
|
// url: '/accounts/login/',
|
|
// method: 'POST',
|
|
// headers: {
|
|
// 'X-CSRFToken': token.value,
|
|
// 'content-type': 'multipart/form-data'
|
|
// },
|
|
// from: true,
|
|
// body: {
|
|
// username: username,
|
|
// password: password,
|
|
// // csrfmiddlewaretoken: token.value
|
|
// }
|
|
// };
|
|
//
|
|
// cy.request(options);
|
|
// cy.getCookie('sessionid').should('exist');
|
|
// cy.visit('/');
|
|
//
|
|
// cy.get('.start-page__title').should('contain', 'skillbox')
|
|
//
|
|
//
|
|
// // cy.visit('/');
|
|
// // cy.getCookie('csrftoken')
|
|
// // .then((csrftoken) => {
|
|
// // const response = cy.request({
|
|
// // method: 'POST',
|
|
// // url: '/login/',
|
|
// // form: true,
|
|
// // body: {
|
|
// // identification: username,
|
|
// // password: password,
|
|
// // csrfmiddlewaretoken: csrftoken.value
|
|
// // }
|
|
// // });
|
|
// // });
|
|
//
|
|
// });
|
|
|
|
|
|
// })
|
|
})
|