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'; beforeEach(function () { // todo: mock all the graphql queries and mutations cy.clearCookies(); cy.visit('/me/profile'); cy.login('rahel.cueni', 'test'); }); after(function () { cy.exec("python ../server/manage.py reset_testuser_password rahel.cueni"); }); it('shows an empty form', () => { 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.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.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.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.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.changePassword(validOldPassword, 'ABCDDD334551!'); cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg) }); it('shows errors if new password has no digit', () => { 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.changePassword(validOldPassword, 'AbcdEEDE09877'); cy.get('[data-cy=new-password-local-errors]').should('contain', validationErrorMsg) }); it('shows errors if old password does not match', () => { cy.changePassword('test12345', validNewPassword); cy.get('[data-cy=old-password-remote-errors]').should('contain', validationOldWrongMsg) }); it('shows success if change was successful', () => { 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', ''); }); });