Update cypress test. Fail login. (#2618)

* added new steps with incorrect user and password

* added className and change cvat-ui version

* improvements closeNotification function

* fixed if it running at firefox

* added className

* fix space on string

* added closeNotification in step

* improvements by comments

Co-authored-by: Dmitriy Oparin <dmitriyx.oparin@intel.com>
main
DmitriyOparin 5 years ago committed by GitHub
parent a04d95dfc5
commit 67c3d6b459
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -146,6 +146,7 @@ export default function (state = defaultState, action: AnyAction): Notifications
login: {
message: 'Could not login on the server',
reason: action.payload.error.toString(),
className: 'cvat-notification-notice-login-failed',
},
},
},

@ -10,6 +10,12 @@ context('When clicking on the Logout button, get the user session closed.', () =
const issueId = '1810';
let taskId;
function login(userName, password) {
cy.get('[placeholder="Username"]').clear().type(userName);
cy.get('[placeholder="Password"]').clear().type(password);
cy.get('[type="submit"]').click();
}
before(() => {
cy.visit('auth/login');
});
@ -25,7 +31,6 @@ context('When clicking on the Logout button, get the user session closed.', () =
});
it('Login and open task', () => {
cy.closeModalUnsupportedPlatform();
cy.login();
cy.openTask(taskName);
// get id task
@ -44,10 +49,8 @@ context('When clicking on the Logout button, get the user session closed.', () =
cy.get('span[aria-label="logout"]').click();
cy.url().should('include', `/auth/login/?next=/tasks/${taskId}`);
// login to task
cy.get('[placeholder="Username"]').type(Cypress.env('user'));
cy.get('[placeholder="Password"]').type(Cypress.env('password'));
cy.get('[type="submit"]').click();
cy.url().should('include', `/tasks/${taskId}`).and('not.include', '/auth/login/');
login(Cypress.env('user'), Cypress.env('password'));
cy.url().should('include', `/tasks/${taskId}`).and('not.include', '/auth/login');
cy.contains('.cvat-task-details-task-name', `${taskName}`).should('be.visible');
});
@ -67,9 +70,27 @@ context('When clicking on the Logout button, get the user session closed.', () =
const csrfToken = responce[0].match(/csrftoken=\w+/)[0].replace('csrftoken=', '');
const sessionId = responce[1].match(/sessionid=\w+/)[0].replace('sessionid=', '');
cy.visit(`/login-with-token/${sessionId}/${csrfToken}?next=/tasks/${taskId}`);
cy.closeModalUnsupportedPlatform();
cy.contains('.cvat-task-details-task-name', `${taskName}`).should('be.visible');
});
});
it('Incorrect user and correct password', () => {
cy.logout();
login('randomUser123', Cypress.env('password'));
cy.url().should('include', '/auth/login');
cy.closeNotification('.cvat-notification-notice-login-failed');
});
it('Correct user and incorrect password', () => {
login(Cypress.env('user'), 'randomPassword123');
cy.url().should('include', '/auth/login');
cy.closeNotification('.cvat-notification-notice-login-failed');
});
it('Incorrect user and incorrect password', () => {
login('randomUser123', 'randomPassword123');
cy.url().should('include', '/auth/login');
cy.closeNotification('.cvat-notification-notice-login-failed');
});
});
});

@ -25,6 +25,7 @@ Cypress.Commands.add('logout', (username = Cypress.env('user')) => {
cy.get('span[aria-label="logout"]').click();
cy.url().should('include', '/auth/login');
cy.visit('/auth/login'); // clear query parameter "next"
cy.closeModalUnsupportedPlatform();
});
Cypress.Commands.add('userRegistration', (firstName, lastName, userName, emailAddr, password) => {
@ -586,6 +587,11 @@ Cypress.Commands.add('goToPreviousFrame', (expectedFrameNum) => {
cy.checkFrameNum(expectedFrameNum);
});
Cypress.Commands.add('closeNotification', (className) => {
cy.get(className).find('span[aria-label="close"]').click();
cy.get(className).should('not.exist');
});
Cypress.Commands.add('getObjectIdNumberByLabelName', (labelName) => {
cy.document().then((doc) => {
const stateItemLabelSelectorList = Array.from(

Loading…
Cancel
Save