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 <dmitriyx.oparin@intel.com>
main
DmitriyOparin 5 years ago committed by GitHub
parent e4c5a78774
commit a04d95dfc5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,6 +47,7 @@ function ChangePasswordComponent(props: ChangePasswordPageComponentProps): JSX.E
return ( return (
<Modal <Modal
className='cvat-modal-change-password'
title={<Title level={3}>Change password</Title>} title={<Title level={3}>Change password</Title>}
okType='primary' okType='primary'
okText='Submit' okText='Submit'

@ -232,7 +232,7 @@ function HeaderContainer(props: Props): JSX.Element {
About About
</Menu.Item> </Menu.Item>
{renderChangePasswordItem && ( {renderChangePasswordItem && (
<Menu.Item onClick={(): void => switchChangePasswordDialog(true)} disabled={changePasswordFetching}> <Menu.Item className='cvat-header-menu-change-password' onClick={(): void => switchChangePasswordDialog(true)} disabled={changePasswordFetching}>
{changePasswordFetching ? <LoadingOutlined /> : <EditOutlined />} {changePasswordFetching ? <LoadingOutlined /> : <EditOutlined />}
Change password Change password
</Menu.Item> </Menu.Item>

@ -222,6 +222,7 @@ export default function (state = defaultState, action: AnyAction): Notifications
changePassword: { changePassword: {
message: 'Could not change password', message: 'Could not change password',
reason: action.payload.error.toString(), reason: action.payload.error.toString(),
className: 'cvat-notification-notice-change-password-failed',
}, },
}, },
}, },

@ -22,6 +22,20 @@ context('Register user, change password, login with new password', () => {
const password = `${randomString(true)}`; const password = `${randomString(true)}`;
const newPassword = `${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(() => { before(() => {
cy.visit('auth/register'); cy.visit('auth/register');
cy.url().should('include', '/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}"`, () => { describe(`Testing "Case ${caseId}"`, () => {
it('Register user, change password', () => { it('Register user, change password', () => {
cy.userRegistration(firstName, lastName, userName, emailAddr, password); cy.userRegistration(firstName, lastName, userName, emailAddr, password);
cy.get('.cvat-right-header') changePassword(userName, password, newPassword);
.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'); cy.contains('New password has been saved.').should('exist');
}); });
it('Logout', () => { it('Logout', () => {
cy.logout(userName); cy.logout(userName);
}); });
it('Login with the new password', () => { it('Login with the new password', () => {
cy.closeModalUnsupportedPlatform();
cy.login(userName, newPassword); 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');
});
}); });
}); });

@ -15,7 +15,7 @@ Cypress.Commands.add('login', (username = Cypress.env('user'), password = Cypres
cy.get('[placeholder="Username"]').type(username); cy.get('[placeholder="Username"]').type(username);
cy.get('[placeholder="Password"]').type(password); cy.get('[placeholder="Password"]').type(password);
cy.get('[type="submit"]').click(); cy.get('[type="submit"]').click();
cy.url().should('include', '/tasks'); cy.url().should('match', /\/tasks$/);
}); });
Cypress.Commands.add('logout', (username = Cypress.env('user')) => { Cypress.Commands.add('logout', (username = Cypress.env('user')) => {

Loading…
Cancel
Save