66 lines
1.9 KiB
JavaScript
66 lines
1.9 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('E-Mail 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('Passwort 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.only('logs out then logs in again', () => {
|
|
cy.viewport('macbook-15');
|
|
cy.apolloLogin('rahel.cueni', 'test');
|
|
cy.visit('/me/my-class');
|
|
cy.get('[data-cy=header-user-widget]').should('exist').within(() => {
|
|
cy.get('[data-cy=user-widget-avatar]').should('exist').click();
|
|
});
|
|
|
|
cy.get('[data-cy=logout]').click();
|
|
|
|
cy.login('rahel.cueni', 'test');
|
|
|
|
cy.get('[data-cy=header-user-widget]').should('exist').within(() => {
|
|
cy.get('[data-cy=user-widget-avatar]').should('exist').click();
|
|
});
|
|
|
|
cy.get('.profile-sidebar').should('be.visible');
|
|
});
|
|
})
|