From aa705417740ced3193646d1b2a82a2333e0b4e8f Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Fri, 13 Nov 2020 16:30:29 +0300 Subject: [PATCH] Added functionality for build CVAT with wmail support --- tests/__init__.py | 3 ++ tests/cypress.json | 1 + .../case_2_register_user_change_pass.js | 2 +- .../case_4_assign_taks_job_users.js | 2 +- .../check_email_verification_system.js | 39 +++++++++++++++++++ .../issue_1599_ch_user_registration.js | 22 +++++++---- .../issue_1599_pl_user_registration.js | 21 ++++++---- .../cypress/integration/remove_users_tasks.js | 1 + tests/docker-compose.email.yml | 4 +- 9 files changed, 75 insertions(+), 20 deletions(-) create mode 100644 tests/__init__.py create mode 100644 tests/cypress/integration/actions_users/check_email_verification_system.js diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 00000000..f19d9bef --- /dev/null +++ b/tests/__init__.py @@ -0,0 +1,3 @@ +# Copyright (C) 2020 Intel Corporation +# +# SPDX-License-Identifier: MIT diff --git a/tests/cypress.json b/tests/cypress.json index 80523cb6..dd68e5fc 100644 --- a/tests/cypress.json +++ b/tests/cypress.json @@ -6,6 +6,7 @@ "defaultCommandTimeout": 25000, "env": { "user": "admin", + "email": "admin@localhost.company", "password": "12qwaszx" }, "testFiles": ["auth_page.js", "actions_tasks_objects/*", "actions_users/*", "remove_users_tasks.js"] diff --git a/tests/cypress/integration/actions_users/case_2_register_user_change_pass.js b/tests/cypress/integration/actions_users/case_2_register_user_change_pass.js index 91b025c1..c0bb0a7a 100644 --- a/tests/cypress/integration/actions_users/case_2_register_user_change_pass.js +++ b/tests/cypress/integration/actions_users/case_2_register_user_change_pass.js @@ -13,7 +13,7 @@ const randomString = (isPassword) => { return isPassword ? `${result}${Math.floor(Math.random() * 10)}` : result; }; -context('Register user, change password, login with new password', () => { +context('Register user, change password, login with new password', { browser: 'chrome' }, () => { const caseId = '2'; const firstName = `${randomString()}`; const lastName = `${randomString()}`; diff --git a/tests/cypress/integration/actions_users/case_4_assign_taks_job_users.js b/tests/cypress/integration/actions_users/case_4_assign_taks_job_users.js index 72a678b2..b11c3764 100644 --- a/tests/cypress/integration/actions_users/case_4_assign_taks_job_users.js +++ b/tests/cypress/integration/actions_users/case_4_assign_taks_job_users.js @@ -4,7 +4,7 @@ /// -context('Multiple users. Assign task, job.', () => { +context('Multiple users. Assign task, job.', { browser: 'chrome' }, () => { const caseId = '4'; const labelName = `Case ${caseId}`; const taskName = `New annotation task for ${labelName}`; diff --git a/tests/cypress/integration/actions_users/check_email_verification_system.js b/tests/cypress/integration/actions_users/check_email_verification_system.js new file mode 100644 index 00000000..8fc44378 --- /dev/null +++ b/tests/cypress/integration/actions_users/check_email_verification_system.js @@ -0,0 +1,39 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +const randomString = (isPassword) => { + let result = ''; + const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'; + for (let i = 0; i <= 8; i++) { + result += characters.charAt(Math.floor(Math.random() * characters.length)); + } + return isPassword ? `${result}${Math.floor(Math.random() * 10)}` : result; +}; + +context('Check email verification system', { browser: 'firefox' }, () => { + const caseId = 'Email verification system'; + const firstName = `${randomString()}`; + const lastName = `${randomString()}`; + const userName = `${randomString()}`; + const emailAddr = `${userName}@local.local`; + const password = `${randomString(true)}`; + + before(() => { + cy.visit('auth/register'); + cy.url().should('include', '/auth/register'); + }); + + describe(`Case: "${caseId}"`, () => { + it('Register user', () => { + cy.server().route('POST', '/api/v1/auth/register').as('userRegister'); + cy.userRegistration(firstName, lastName, userName, emailAddr, password); + cy.get('.ant-notification-topRight') + .contains(`We have sent an email with a confirmation link to ${emailAddr}.`) + .should('exist') + cy.wait('@userRegister').its('status').should('eq', 201); + }); + }); +}); diff --git a/tests/cypress/integration/actions_users/issue_1599_ch_user_registration.js b/tests/cypress/integration/actions_users/issue_1599_ch_user_registration.js index 08cda62c..92db957e 100644 --- a/tests/cypress/integration/actions_users/issue_1599_ch_user_registration.js +++ b/tests/cypress/integration/actions_users/issue_1599_ch_user_registration.js @@ -4,7 +4,14 @@ /// -context('Issue 1599 (Chinese alphabet).', () => { +context('Issue 1599 (Chinese alphabet).', { browser: 'chrome' }, () => { + + const firstName = '测试者' + const lastName = '测试' + const userName = 'Testuser_ch' + const email = 'Testuser_ch@local.local' + const password = 'Qwerty123!' + before(() => { cy.visit('auth/register'); cy.url().should('include', '/auth/register'); @@ -12,33 +19,32 @@ context('Issue 1599 (Chinese alphabet).', () => { describe('User registration using the Chinese alphabet.', () => { it('Filling in the placeholder "First name"', () => { - cy.get('[placeholder="First name"]').type('测试者').should('not.have.class', 'has-error'); + cy.get('[placeholder="First name"]').type(firstName).should('not.have.class', 'has-error'); }); it('Filling in the placeholder "Last name"', () => { - cy.get('[placeholder="Last name"]').type('测试').should('not.have.class', 'has-error'); + cy.get('[placeholder="Last name"]').type(lastName).should('not.have.class', 'has-error'); }); it('Filling in the placeholder "Username"', () => { - cy.get('[placeholder="Username"]').type('Testuser_ch'); + cy.get('[placeholder="Username"]').type(userName); }); it('Filling in the placeholder "Email address"', () => { - cy.get('[placeholder="Email address"]').type('Testuser_ch@local.local'); + cy.get('[placeholder="Email address"]').type(email); }); it('Filling in the placeholder "Password"', () => { - cy.get('[placeholder="Password"]').type('Qwerty123!'); + cy.get('[placeholder="Password"]').type(password); }); it('Filling in the placeholder "Confirm password"', () => { - cy.get('[placeholder="Confirm password"]').type('Qwerty123!'); + cy.get('[placeholder="Confirm password"]').type(password); }); it('Click to "Submit" button', () => { cy.get('[type="submit"]').click(); }); - it('Successful registration', () => { cy.url().should('include', '/tasks'); }); diff --git a/tests/cypress/integration/actions_users/issue_1599_pl_user_registration.js b/tests/cypress/integration/actions_users/issue_1599_pl_user_registration.js index 11a48a15..53b169f7 100644 --- a/tests/cypress/integration/actions_users/issue_1599_pl_user_registration.js +++ b/tests/cypress/integration/actions_users/issue_1599_pl_user_registration.js @@ -4,7 +4,14 @@ /// -context('Issue 1599 (Polish alphabet).', () => { +context('Issue 1599 (Polish alphabet).', { browser: 'chrome' }, () => { + + const firstName = 'Świętobor' + const lastName = 'Сzcić' + const userName = 'Testuser_pl' + const email = 'Testuser_pl@local.local' + const password = 'Qwerty123!' + before(() => { cy.visit('auth/register'); cy.url().should('include', '/auth/register'); @@ -12,27 +19,27 @@ context('Issue 1599 (Polish alphabet).', () => { describe('User registration using the Polish alphabet.', () => { it('Filling in the placeholder "First name"', () => { - cy.get('[placeholder="First name"]').type('Świętobor').should('not.have.class', 'has-error'); + cy.get('[placeholder="First name"]').type(firstName).should('not.have.class', 'has-error'); }); it('Filling in the placeholder "Last name"', () => { - cy.get('[placeholder="Last name"]').type('Сzcić').should('not.have.class', 'has-error'); + cy.get('[placeholder="Last name"]').type(lastName).should('not.have.class', 'has-error'); }); it('Filling in the placeholder "Username"', () => { - cy.get('[placeholder="Username"]').type('Testuser_pl'); + cy.get('[placeholder="Username"]').type(userName); }); it('Filling in the placeholder "Email address"', () => { - cy.get('[placeholder="Email address"]').type('Testuser_pl@local.local'); + cy.get('[placeholder="Email address"]').type(email); }); it('Filling in the placeholder "Password"', () => { - cy.get('[placeholder="Password"]').type('Qwerty123!'); + cy.get('[placeholder="Password"]').type(password); }); it('Filling in the placeholder "Confirm password"', () => { - cy.get('[placeholder="Confirm password"]').type('Qwerty123!'); + cy.get('[placeholder="Confirm password"]').type(password); }); it('Click to "Submit" button', () => { diff --git a/tests/cypress/integration/remove_users_tasks.js b/tests/cypress/integration/remove_users_tasks.js index f6be5763..e30bafdc 100644 --- a/tests/cypress/integration/remove_users_tasks.js +++ b/tests/cypress/integration/remove_users_tasks.js @@ -13,6 +13,7 @@ describe('Delete users and tasks created during the test run.', () => { url: '/api/v1/auth/login', body: { username: Cypress.env('user'), + email: Cypress.env('email'), password: Cypress.env('password'), }, }).then(async (responce) => { diff --git a/tests/docker-compose.email.yml b/tests/docker-compose.email.yml index 452546f3..962376a5 100644 --- a/tests/docker-compose.email.yml +++ b/tests/docker-compose.email.yml @@ -2,7 +2,5 @@ version: "3.3" services: cvat: - volumes: - - ./email_settings.py:/home/django/email_settings.py:ro environment: - DJANGO_SETTINGS_MODULE: email_settings + DJANGO_SETTINGS_MODULE: tests.email_settings