diff --git a/tests/cypress.json b/tests/cypress.json index 51422aa13a7f..59316936ea24 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -4,6 +4,10 @@ "viewportWidth": 1300, "viewportHeight": 960, "defaultCommandTimeout": 10000, + "env": { + "user": "admin", + "password": "12qwaszx" + }, "testFiles": [ "auth_page.js", "issue_*.js" diff --git a/tests/cypress/integration/issue_1810_login_logout.js b/tests/cypress/integration/issue_1810_login_logout.js new file mode 100644 index 000000000000..44a943e9ec8b --- /dev/null +++ b/tests/cypress/integration/issue_1810_login_logout.js @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('When clicking on the Logout button, get the user session closed.', () => { + + const issueId = '1810' + + before(() => { + cy.visit('auth/login') + }) + + describe(`Testing issue "${issueId}"`, () => { + it('Login', () => { + cy.login() + cy.url().should('include', '/tasks') + }) + it('Logout', () => { + cy.logout() + cy.url().should('include', '/auth/login') + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index e0fea571d4cb..06ad6b38a7a8 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -10,12 +10,21 @@ require('cypress-file-upload') require('../plugins/imageGenerator/imageGeneratorCommand') require('../plugins/createZipArchive/createZipArchiveCommand') -Cypress.Commands.add('login', (username='admin', password='12qwaszx') => { +Cypress.Commands.add('login', (username=Cypress.env('user'), password=Cypress.env('password')) => { cy.get('[placeholder="Username"]').type(username) cy.get('[placeholder="Password"]').type(password) cy.get('[type="submit"]').click() }) +Cypress.Commands.add('logout', (username=Cypress.env('user')) => { + cy.get('.cvat-right-header') + .find('.cvat-header-menu-dropdown') + .should('have.text', username) + .trigger('mouseover', {which: 1}) + cy.get('.anticon-logout') + .click() +}) + Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task', labelName='Some label', attrName='Some attr name',