96 lines
3.5 KiB
JavaScript
96 lines
3.5 KiB
JavaScript
describe('Change Password Page', () => {
|
|
|
|
const validNewPassword = 'Abcd1234!';
|
|
const validOldPassword = 'test';
|
|
const validationTooShort = 'Das neue Passwort muss mindestens 8 Zeichen lang sein';
|
|
const validationErrorMsg = 'Das Passwort muss Grossbuchstaben, Zahlen und Sonderzeichen beinhalten';
|
|
const validationOldWrongMsg = 'Die Eingabe ist falsch';
|
|
|
|
after(function () {
|
|
cy.exec("python ../server/manage.py reset_testuser_password rahel.cueni");
|
|
});
|
|
|
|
it('shows an empty form', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.get('[data-cy=password-change-success]').should('not.exist');
|
|
cy.get('[data-cy=old-password]').should('have.value', '');
|
|
cy.get('[data-cy=new-password]').should('have.value', '');
|
|
});
|
|
|
|
it('shows errors if old password is not entered', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword('', validNewPassword);
|
|
cy.get('[data-cy=old-password-local-errors]').should('contain', 'Dein aktuelles Passwort fehlt')
|
|
});
|
|
|
|
it('shows errors if new password is not entered', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, '');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', 'Dein neues Passwort fehlt')
|
|
});
|
|
|
|
it('shows errors if new password is too short', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, 'Abc1!');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', validationTooShort)
|
|
});
|
|
|
|
it('shows errors if new password has no uppercase letter', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, 'aabdddedddbc1!');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg)
|
|
});
|
|
|
|
it('shows errors if new password has no lowercase letter', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, 'ABCDDD334551!');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg)
|
|
});
|
|
|
|
it('shows errors if new password has no digit', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, 'AbcdEEDE!');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg)
|
|
});
|
|
|
|
it('shows errors if new password has no special character', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, 'AbcdEEDE09877');
|
|
cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg)
|
|
});
|
|
|
|
it('shows errors if old password does not match', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword('test12345', validNewPassword);
|
|
cy.get('[data-cy=old-password-remote-errors]').should('contain', validationOldWrongMsg)
|
|
});
|
|
|
|
it('shows success if change was successful', () => {
|
|
cy.login('rahel.cueni', 'test');
|
|
cy.visit('/me/password-change');
|
|
|
|
cy.changePassword(validOldPassword, validNewPassword);
|
|
cy.get('[data-cy=password-change-success]').should('contain', 'Dein Password wurde erfolgreich geändert.');
|
|
cy.get('[data-cy=old-password]').should('have.value', '');
|
|
cy.get('[data-cy=new-password]').should('have.value', '');
|
|
});
|
|
});
|