From a04d95dfc5e9a364fa996fa950029fc844348ed5 Mon Sep 17 00:00:00 2001 From: DmitriyOparin <35344996+DmitriyOparin@users.noreply.github.com> Date: Wed, 30 Dec 2020 16:20:26 +0300 Subject: [PATCH] Update cypress test. Change password fail. (#2619) * added step change password with incorrect password * added cssSelectors for elements and changed cvat-ui version * rename step * improvements by comment * fix if test running in firefox Co-authored-by: Dmitriy Oparin --- .../change-password-modal.tsx | 1 + cvat-ui/src/components/header/header.tsx | 2 +- cvat-ui/src/reducers/notifications-reducer.ts | 1 + .../case_2_register_user_change_pass.js | 31 ++++++++++++------- tests/cypress/support/commands.js | 2 +- 5 files changed, 24 insertions(+), 13 deletions(-) diff --git a/cvat-ui/src/components/change-password-modal/change-password-modal.tsx b/cvat-ui/src/components/change-password-modal/change-password-modal.tsx index d3a3c0fe..2b7b962d 100644 --- a/cvat-ui/src/components/change-password-modal/change-password-modal.tsx +++ b/cvat-ui/src/components/change-password-modal/change-password-modal.tsx @@ -47,6 +47,7 @@ function ChangePasswordComponent(props: ChangePasswordPageComponentProps): JSX.E return ( Change password} okType='primary' okText='Submit' diff --git a/cvat-ui/src/components/header/header.tsx b/cvat-ui/src/components/header/header.tsx index 7c10e621..8b5ac047 100644 --- a/cvat-ui/src/components/header/header.tsx +++ b/cvat-ui/src/components/header/header.tsx @@ -232,7 +232,7 @@ function HeaderContainer(props: Props): JSX.Element { About {renderChangePasswordItem && ( - switchChangePasswordDialog(true)} disabled={changePasswordFetching}> + switchChangePasswordDialog(true)} disabled={changePasswordFetching}> {changePasswordFetching ? : } Change password diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts index 848548a7..3e8d0a96 100644 --- a/cvat-ui/src/reducers/notifications-reducer.ts +++ b/cvat-ui/src/reducers/notifications-reducer.ts @@ -222,6 +222,7 @@ export default function (state = defaultState, action: AnyAction): Notifications changePassword: { message: 'Could not change password', reason: action.payload.error.toString(), + className: 'cvat-notification-notice-change-password-failed', }, }, }, diff --git a/tests/cypress/integration/actions_users/registration_involved/case_2_register_user_change_pass.js b/tests/cypress/integration/actions_users/registration_involved/case_2_register_user_change_pass.js index 1eddfc9b..adf65255 100644 --- a/tests/cypress/integration/actions_users/registration_involved/case_2_register_user_change_pass.js +++ b/tests/cypress/integration/actions_users/registration_involved/case_2_register_user_change_pass.js @@ -22,6 +22,20 @@ context('Register user, change password, login with new password', () => { const password = `${randomString(true)}`; const newPassword = `${randomString(true)}`; + function changePassword(userName, password, newPassword) { + cy.get('.cvat-right-header') + .find('.cvat-header-menu-dropdown') + .should('have.text', userName) + .trigger('mouseover'); + cy.get('.cvat-header-menu-change-password').click(); + cy.get('.cvat-modal-change-password').within(() => { + cy.get('#oldPassword').type(password); + cy.get('#newPassword1').type(newPassword); + cy.get('#newPassword2').type(newPassword); + cy.get('.change-password-form-button').click(); + }); + } + before(() => { cy.visit('auth/register'); cy.url().should('include', '/auth/register'); @@ -30,24 +44,19 @@ context('Register user, change password, login with new password', () => { describe(`Testing "Case ${caseId}"`, () => { it('Register user, change password', () => { cy.userRegistration(firstName, lastName, userName, emailAddr, password); - cy.get('.cvat-right-header') - .find('.cvat-header-menu-dropdown') - .should('have.text', userName) - .trigger('mouseover'); - cy.get('.anticon-edit').click(); - cy.get('.ant-modal-body').within(() => { - cy.get('#oldPassword').type(password); - cy.get('#newPassword1').type(newPassword); - cy.get('#newPassword2').type(newPassword); - cy.get('.change-password-form-button').click(); - }); + changePassword(userName, password, newPassword); cy.contains('New password has been saved.').should('exist'); }); it('Logout', () => { cy.logout(userName); }); it('Login with the new password', () => { + cy.closeModalUnsupportedPlatform(); cy.login(userName, newPassword); }); + it('Change password with incorrect current password', () => { + changePassword(userName, `${randomString(true)}`, newPassword); + cy.get('.cvat-notification-notice-change-password-failed').should('exist'); + }); }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 4e75bf1d..91908927 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -15,7 +15,7 @@ Cypress.Commands.add('login', (username = Cypress.env('user'), password = Cypres cy.get('[placeholder="Username"]').type(username); cy.get('[placeholder="Password"]').type(password); cy.get('[type="submit"]').click(); - cy.url().should('include', '/tasks'); + cy.url().should('match', /\/tasks$/); }); Cypress.Commands.add('logout', (username = Cypress.env('user')) => {