diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts index 3e8d0a96..1559e399 100644 --- a/cvat-ui/src/reducers/notifications-reducer.ts +++ b/cvat-ui/src/reducers/notifications-reducer.ts @@ -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', }, }, }, diff --git a/tests/cypress/integration/actions_users/issue_1810_login_logout.js b/tests/cypress/integration/actions_users/issue_1810_login_logout.js index c37948b5..f6a94720 100644 --- a/tests/cypress/integration/actions_users/issue_1810_login_logout.js +++ b/tests/cypress/integration/actions_users/issue_1810_login_logout.js @@ -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'); + }); }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 91908927..d15429bb 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -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(