From 4dc25e20c9e4fa8878a5761d1e2a5d9b8cedac4b Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Mon, 14 Sep 2020 08:32:18 +0300 Subject: [PATCH] Cypress test to check change user password and login with the new (#2159) password. Co-authored-by: Dmitry Kruchinin --- .../case_2_register_user_change_pass.js | 51 +++++++++++++++++++ tests/cypress/support/commands.js | 10 ++++ 2 files changed, 61 insertions(+) create mode 100644 tests/cypress/integration/case_2_register_user_change_pass.js diff --git a/tests/cypress/integration/case_2_register_user_change_pass.js b/tests/cypress/integration/case_2_register_user_change_pass.js new file mode 100644 index 00000000..972293ea --- /dev/null +++ b/tests/cypress/integration/case_2_register_user_change_pass.js @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Register user, change password, login with new password', () => { + const caseId = '2' + const firstName = 'First name' + const lastName = 'Last name' + const userName = 'Username' + const emailAddr = `${userName}@local.local` + const password = 'UfdU21!dds' + const newPassword = 'dKl3j49sd@jjk' + + before(() => { + cy.visit('auth/register') + cy.url().should('include', '/auth/register') + }) + + describe(`Testing "Case ${caseId}"`, () => { + it('Register user, change password', () => { + cy.userRegistration(firstName, lastName, userName, emailAddr, password) + cy.url().should('include', '/tasks') + 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() + }) + cy.contains('New password has been saved.') + .should('exist') + }) + it('Logout', () => { + cy.logout(userName) + cy.url().should('include', '/auth/login') + }) + it('Login with the new password', () => { + cy.login(userName, newPassword) + cy.url().should('include', '/tasks') + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index c5fbc563..b18fb808 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -25,6 +25,16 @@ Cypress.Commands.add('logout', (username=Cypress.env('user')) => { .click() }) +Cypress.Commands.add('userRegistration', (firstName, lastName, userName, emailAddr, password) => { + cy.get('#firstName').type(firstName) + cy.get('#lastName').type(lastName) + cy.get('#username').type(userName) + cy.get('#email').type(emailAddr) + cy.get('#password1').type(password) + cy.get('#password2').type(password) + cy.get('.register-form-button').click() +}) + Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task', labelName='Some label', attrName='Some attr name',