Cypress. New organization pipeline. (#4143)
* The folder renamed * Add classes * Rename the folder * Rename/rework the script for remoing users, tasts, projects, organizations * Added commands for organizations * Fix eslint issues * Fix workflow * Move the test to the registration_involved folder * Added class * Update the test. Added some commands. * Added class * Add a command. Updated the test. * Fix eslint issue * Added some classes * Added cypress command. Update corespinding test. * Continue writin the test. Update commands. * Continue writing the test * Update main.yml * Add className * Update the test. Add command * Update the test * Added command for remove a tasks, users, progects, orgs * Some reworks * Add a class * Update the test * Added check issue 4096 * Update year * Update years * Update the stept in the test * Rework command to remove users, etc. * The tests adaptation * Rework command to deleting users, etc. * Apply comments * Revert changes except base_actions_project test * Rename the command to delete a task by api * Apply commenst. Split tests * Update the command, the test. * Added steps to check * Fix support/index.js * The test adaptation. * Removed comments. Co-authored-by: dvkruchinin <dvkruchinin@gmail.com>main
parent
85cb87bf31
commit
e212d57136
@ -0,0 +1,299 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
context('New organization pipeline.', () => {
|
||||
const caseId = '113';
|
||||
const firstUserName = 'Firstuser';
|
||||
const secondUserName = 'Seconduser';
|
||||
const thirdUserName = 'Thirduser';
|
||||
|
||||
const firstUser = {
|
||||
firstName: `${firstUserName} fitstname`,
|
||||
lastName: `${firstUserName} lastname`,
|
||||
emailAddr: `${firstUserName.toLowerCase()}@local.local`,
|
||||
password: 'UfdU21!dds',
|
||||
};
|
||||
const secondUser = {
|
||||
firstName: `${secondUserName} fitstname`,
|
||||
lastName: `${secondUserName} lastname`,
|
||||
emailAddr: `${secondUserName.toLowerCase()}@local.local`,
|
||||
password: 'UfdU21!dds',
|
||||
};
|
||||
const thirdUser = {
|
||||
firstName: `${thirdUserName} fitstname`,
|
||||
lastName: `${thirdUserName} lastname`,
|
||||
emailAddr: `${thirdUserName.toLowerCase()}@local.local`,
|
||||
password: 'Fv5Df3#f55g',
|
||||
};
|
||||
const organizationParams = {
|
||||
shortName: 'TestOrganization',
|
||||
fullName: 'Organization full name. Only for test.',
|
||||
description: 'This organization was created to test the functionality.',
|
||||
email: 'testorganization@local.local',
|
||||
phoneNumber: '+70000000000',
|
||||
location: 'Country, State, Address, 000000',
|
||||
};
|
||||
const project = {
|
||||
name: `Project case ${caseId}`,
|
||||
label: 'car',
|
||||
attrName: 'color',
|
||||
attrVaue: 'red',
|
||||
multiAttrParams: false,
|
||||
};
|
||||
|
||||
const labelName = `Case ${caseId}`;
|
||||
const taskName = `New annotation task for ${labelName}`;
|
||||
const newTaskName = labelName;
|
||||
const attrName = `Attr for ${labelName}`;
|
||||
const textDefaultValue = 'Some default value for type Text';
|
||||
const imagesCount = 1;
|
||||
const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}`;
|
||||
const width = 800;
|
||||
const height = 800;
|
||||
const posX = 10;
|
||||
const posY = 10;
|
||||
const color = 'gray';
|
||||
const archiveName = `${imageFileName}.zip`;
|
||||
const archivePath = `cypress/fixtures/${archiveName}`;
|
||||
const imagesFolder = `cypress/fixtures/${imageFileName}`;
|
||||
const directoryToArchive = imagesFolder;
|
||||
let taskID;
|
||||
let jobID;
|
||||
|
||||
const createCuboidShape2Points = {
|
||||
points: 'From rectangle',
|
||||
type: 'Shape',
|
||||
labelName,
|
||||
firstX: 250,
|
||||
firstY: 350,
|
||||
secondX: 350,
|
||||
secondY: 450,
|
||||
};
|
||||
|
||||
function capitalizeEmail(email) {
|
||||
return email.split('@').map((part) => `${part.toUpperCase()[0]}${part.slice(1)}`).join('@');
|
||||
}
|
||||
|
||||
before(() => {
|
||||
cy.imageGenerator(
|
||||
imagesFolder,
|
||||
imageFileName,
|
||||
width,
|
||||
height,
|
||||
color,
|
||||
posX,
|
||||
posY,
|
||||
project.label,
|
||||
imagesCount,
|
||||
);
|
||||
cy.createZipArchive(directoryToArchive, archivePath);
|
||||
|
||||
cy.visit('/');
|
||||
cy.goToRegisterPage();
|
||||
cy.userRegistration(
|
||||
secondUser.firstName,
|
||||
secondUser.lastName,
|
||||
secondUserName,
|
||||
secondUser.emailAddr,
|
||||
secondUser.password,
|
||||
);
|
||||
cy.logout(secondUserName);
|
||||
|
||||
cy.goToRegisterPage();
|
||||
cy.userRegistration(
|
||||
thirdUser.firstName,
|
||||
thirdUser.lastName,
|
||||
thirdUserName,
|
||||
thirdUser.emailAddr,
|
||||
thirdUser.password,
|
||||
);
|
||||
cy.logout(thirdUserName);
|
||||
|
||||
cy.goToRegisterPage();
|
||||
cy.userRegistration(
|
||||
firstUser.firstName,
|
||||
firstUser.lastName,
|
||||
firstUserName,
|
||||
firstUser.emailAddr,
|
||||
firstUser.password,
|
||||
);
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
Cypress.Cookies.preserveOnce('sessionid', 'csrftoken');
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.logout(thirdUserName);
|
||||
cy.getAuthKey().then((authKey) => {
|
||||
cy.deleteUsers(authKey, [thirdUserName]);
|
||||
cy.deleteTasks(authKey, [newTaskName]);
|
||||
cy.deleteProjects(authKey, [project.name]);
|
||||
cy.deleteOrganizations(authKey, [organizationParams.shortName]);
|
||||
});
|
||||
});
|
||||
|
||||
describe(`Testing case "${caseId}"`, () => {
|
||||
it('The first user creates an organization and activates it.', () => {
|
||||
cy.createOrganization(organizationParams);
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
});
|
||||
|
||||
it('Open the organization settings. Invite members.', () => {
|
||||
cy.openOrganization(organizationParams.shortName);
|
||||
cy.checkOrganizationParams(organizationParams);
|
||||
cy.checkOrganizationMembers(1, [firstUserName]);
|
||||
const membersToInvite = [
|
||||
{
|
||||
email: capitalizeEmail(secondUser.emailAddr),
|
||||
role: 'Worker',
|
||||
},
|
||||
{
|
||||
email: thirdUser.emailAddr,
|
||||
role: 'Worker',
|
||||
},
|
||||
];
|
||||
cy.inviteMembersToOrganization(membersToInvite);
|
||||
cy.checkOrganizationMembers(3, [firstUserName, secondUserName, thirdUserName]);
|
||||
});
|
||||
|
||||
it('Create a project, create a task. Deactivate organization.', () => {
|
||||
cy.goToProjectsList();
|
||||
cy.createProjects(
|
||||
project.name,
|
||||
project.label,
|
||||
project.attrName,
|
||||
project.attrVaue,
|
||||
project.multiAttrParams,
|
||||
);
|
||||
cy.goToTaskList();
|
||||
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName);
|
||||
cy.openTask(taskName);
|
||||
cy.assignTaskToUser(secondUserName);
|
||||
cy.deactivateOrganization();
|
||||
});
|
||||
|
||||
it('The project, the task are invisible now.', () => {
|
||||
cy.contains('.cvat-item-task-name', taskName).should('not.exist');
|
||||
cy.goToProjectsList();
|
||||
cy.contains('.cvat-projects-project-item-title', project.name).should('not.exist');
|
||||
});
|
||||
|
||||
it('Admin tries to leave from organization (not successfully because he is not a member of it).', () => {
|
||||
cy.logout(firstUserName);
|
||||
cy.login();
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.openOrganization(organizationParams.shortName);
|
||||
cy.contains('button', 'Leave organization').should('be.visible').click();
|
||||
cy.get('.cvat-modal-organization-leave-confirm')
|
||||
.should('be.visible')
|
||||
.within(() => {
|
||||
cy.contains('button', 'Leave').click();
|
||||
});
|
||||
cy.get('.cvat-notification-notice-leave-organization-failed').should('exist');
|
||||
cy.closeNotification('.cvat-notification-notice-leave-organization-failed');
|
||||
});
|
||||
|
||||
it('The second user login. The user is able to see the organization, can\'t see the task.', () => {
|
||||
cy.logout();
|
||||
cy.login(secondUserName, secondUser.password);
|
||||
cy.checkOrganizationExists(organizationParams.shortName);
|
||||
cy.contains('.cvat-item-task-name', taskName).should('not.exist');
|
||||
});
|
||||
|
||||
it('The second user activates the organization, can\'t see the project because it is not assigned to him.', () => {
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.goToProjectsList();
|
||||
cy.contains('.cvat-projects-project-item-title', project.name).should('not.exist');
|
||||
});
|
||||
|
||||
it('The first user login. Assigne the project to the second user.', () => {
|
||||
cy.logout(secondUserName);
|
||||
cy.login(firstUserName, firstUser.password);
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.goToProjectsList();
|
||||
cy.openProject(project.name);
|
||||
cy.assignProjectToUser(secondUserName);
|
||||
});
|
||||
|
||||
it('The second user login. Now he sees the project and can open it.', () => {
|
||||
cy.logout(firstUserName);
|
||||
cy.login(secondUserName, secondUser.password);
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.goToProjectsList();
|
||||
cy.openProject(project.name);
|
||||
});
|
||||
|
||||
it('Open the task, assign one of jobs to the third user. Rename the task.', () => {
|
||||
cy.goToTaskList();
|
||||
cy.openTask(taskName);
|
||||
cy.assignJobToUser(0, thirdUserName);
|
||||
cy.renameTask(taskName, newTaskName);
|
||||
cy.url().then((url) => {
|
||||
taskID = Number(url.split('/').slice(-1)[0]);
|
||||
});
|
||||
cy.getJobNum(0).then(($jobID) => {
|
||||
jobID = $jobID;
|
||||
});
|
||||
});
|
||||
|
||||
it('Logout, the third user login. The user does not see the project, the task. The user can\'t open the job using direct link.', () => {
|
||||
cy.logout(secondUserName);
|
||||
cy.login(thirdUserName, thirdUser.password);
|
||||
cy.contains('.cvat-item-task-name', taskName).should('not.exist');
|
||||
cy.goToProjectsList();
|
||||
cy.contains('.cvat-projects-project-item-title', project.name).should('not.exist');
|
||||
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
|
||||
cy.get('.cvat-canvas-container').should('not.exist');
|
||||
cy.get('.cvat-notification-notice-fetch-job-failed').should('be.visible');
|
||||
cy.closeNotification('.cvat-notification-notice-fetch-job-failed');
|
||||
});
|
||||
|
||||
it('The third user activates the organization. Now can open the job using direct link. Create an object, save annotations.', () => {
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
|
||||
cy.get('.cvat-canvas-container').should('exist');
|
||||
cy.createCuboid(createCuboidShape2Points);
|
||||
cy.saveJob();
|
||||
});
|
||||
|
||||
it('The owner of the organization removes the second user from it.', () => {
|
||||
cy.logout(thirdUserName);
|
||||
cy.login(firstUserName, firstUser.password);
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.openOrganization(organizationParams.shortName);
|
||||
cy.removeMemberFromOrganization(secondUserName);
|
||||
cy.checkOrganizationMembers(2, [firstUserName, thirdUserName]);
|
||||
});
|
||||
|
||||
it('The organization, project, task is no longer available to the second user.', () => {
|
||||
cy.logout(firstUserName);
|
||||
cy.login(secondUserName, secondUser.password);
|
||||
cy.checkOrganizationExists(organizationParams.shortName, false);
|
||||
cy.contains('.cvat-item-task-name', taskName).should('not.exist');
|
||||
cy.goToProjectsList();
|
||||
cy.contains('.cvat-projects-project-item-title', project.name).should('not.exist');
|
||||
});
|
||||
|
||||
it('Logout. Remove the first, the second user (deletion occurs from user admin).', () => {
|
||||
cy.logout(secondUserName);
|
||||
cy.getAuthKey().then((authKey) => {
|
||||
cy.deleteUsers(authKey, [firstUserName, secondUserName]);
|
||||
});
|
||||
});
|
||||
|
||||
it('Login as the third user. The organization page can be opened. The job can be opened.', () => {
|
||||
cy.login(thirdUserName, thirdUser.password);
|
||||
cy.activateOrganization(organizationParams.shortName);
|
||||
cy.visit('/organization');
|
||||
cy.checkOrganizationParams(organizationParams);
|
||||
cy.checkOrganizationMembers(1, [thirdUserName]);
|
||||
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
|
||||
cy.get('.cvat-canvas-container').should('exist');
|
||||
cy.get('.cvat_canvas_shape_cuboid').should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -0,0 +1,183 @@
|
||||
// Copyright (C) 2022 Intel Corporation
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
/// <reference types="cypress" />
|
||||
|
||||
Cypress.Commands.add('createOrganization', (organizationParams) => {
|
||||
cy.get('.cvat-header-menu-user-dropdown').trigger('mouseover');
|
||||
cy.get('.cvat-header-menu')
|
||||
.should('be.visible')
|
||||
.find('[role="menuitem"]')
|
||||
.filter(':contains("Organization")')
|
||||
.trigger('mouseover');
|
||||
cy.get('.cvat-header-menu-create-organization')
|
||||
.should('be.visible')
|
||||
.click();
|
||||
cy.url().should('contain', '/organizations/create');
|
||||
cy.get('.cvat-create-organization-form').should('be.visible').within(() => {
|
||||
cy.get('#slug').type(organizationParams.shortName);
|
||||
cy.get('#name').type(organizationParams.fullName);
|
||||
cy.get('#description').type(organizationParams.description);
|
||||
cy.get('#email').type(organizationParams.email);
|
||||
cy.get('#phoneNumber').type(organizationParams.phoneNumber);
|
||||
cy.get('#location').type(organizationParams.location);
|
||||
cy.intercept('POST', '/api/v1/organizations**').as('createOrganizations');
|
||||
cy.get('[type="submit"]').click();
|
||||
cy.wait('@createOrganizations').its('response.statusCode').should('equal', 201);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('deleteOrganizations', (authResponse, otrganizationsToDelete) => {
|
||||
const authKey = authResponse.body.key;
|
||||
cy.request({
|
||||
url: '/api/v1/organizations?page_size=all',
|
||||
headers: {
|
||||
Authorization: `Token ${authKey}`,
|
||||
},
|
||||
}).then((_response) => {
|
||||
const responceResult = _response.body;
|
||||
for (const organization of responceResult) {
|
||||
const { id, slug } = organization;
|
||||
for (const organizationToDelete of otrganizationsToDelete) {
|
||||
if (slug === organizationToDelete) {
|
||||
cy.request({
|
||||
method: 'DELETE',
|
||||
url: `/api/v1/organizations/${id}`,
|
||||
headers: {
|
||||
Authorization: `Token ${authKey}`,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('activateOrganization', (organizationShortName) => {
|
||||
cy.get('.cvat-header-menu-user-dropdown').trigger('mouseover');
|
||||
cy.get('.ant-dropdown')
|
||||
.should('be.visible')
|
||||
.not('ant-dropdown-hidden')
|
||||
.find('[role="menuitem"]')
|
||||
.filter(':contains("Organization")')
|
||||
.trigger('mouseover');
|
||||
cy.contains('.cvat-header-menu-organization-item', organizationShortName).click();
|
||||
cy.get('.cvat-header-menu-user-dropdown').should('be.visible');
|
||||
cy.get('.cvat-header-menu-user-dropdown-organization')
|
||||
.should('exist')
|
||||
.and('have.text', organizationShortName);
|
||||
});
|
||||
|
||||
Cypress.Commands.add('deactivateOrganization', () => {
|
||||
cy.get('.cvat-header-menu-user-dropdown').trigger('mouseover');
|
||||
cy.get('.ant-dropdown')
|
||||
.should('be.visible')
|
||||
.not('ant-dropdown-hidden')
|
||||
.find('[role="menuitem"]')
|
||||
.filter(':contains("Organization")')
|
||||
.trigger('mouseover');
|
||||
cy.contains('.cvat-header-menu-organization-item', 'Personal workspace').click();
|
||||
cy.get('.cvat-header-menu-user-dropdown').should('be.visible');
|
||||
cy.get('.cvat-header-menu-user-dropdown-organization').should('not.exist');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('openOrganization', (organizationShortName) => {
|
||||
cy.get('.cvat-header-menu-user-dropdown').trigger('mouseover');
|
||||
cy.get('.ant-dropdown')
|
||||
.should('be.visible')
|
||||
.not('ant-dropdown-hidden')
|
||||
.find('[role="menuitem"]')
|
||||
.filter(':contains("Organization")')
|
||||
.trigger('mouseover');
|
||||
cy.get('.cvat-header-menu-active-organization-item')
|
||||
.should('have.text', organizationShortName);
|
||||
cy.get('.cvat-header-menu-open-organization')
|
||||
.should('be.visible')
|
||||
.click();
|
||||
cy.get('.cvat-organization-page').should('exist').and('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkOrganizationExists', (organizationShortName, shouldExist = true) => {
|
||||
cy.get('.cvat-header-menu-user-dropdown').trigger('mouseover');
|
||||
cy.get('.ant-dropdown')
|
||||
.should('be.visible')
|
||||
.not('ant-dropdown-hidden')
|
||||
.find('[role="menuitem"]')
|
||||
.filter(':contains("Organization")')
|
||||
.trigger('mouseover');
|
||||
if (shouldExist) {
|
||||
cy.contains('.cvat-header-menu-organization-item', organizationShortName)
|
||||
.should('exist')
|
||||
.trigger('mouseout')
|
||||
.should('be.hidden');
|
||||
} else {
|
||||
cy.contains('.cvat-header-menu-organization-item', organizationShortName).should('not.exist');
|
||||
cy.get('.cvat-header-menu-active-organization-item').trigger('mouseout').should('be.hidden');
|
||||
}
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkOrganizationParams', (organizationParams) => {
|
||||
cy.get('.cvat-organization-top-bar-descriptions').then((orgDescriptions) => {
|
||||
const orgDescText = orgDescriptions.text();
|
||||
expect(orgDescText).contain(organizationParams.shortName);
|
||||
expect(orgDescText).contain(organizationParams.fullName);
|
||||
expect(orgDescText).contain(organizationParams.description);
|
||||
});
|
||||
cy.get('.cvat-organization-top-bar-contacts').then((orgContacts) => {
|
||||
const orgContactsText = orgContacts.text();
|
||||
expect(orgContactsText).contain(organizationParams.email);
|
||||
expect(orgContactsText).contain(organizationParams.phoneNumber);
|
||||
expect(orgContactsText).contain(organizationParams.location);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('checkOrganizationMembers', (expectedMembersCount, expectedOrganizationMembers) => {
|
||||
const orgMembersUserameText = [];
|
||||
cy.get('.cvat-organization-member-item').should('have.length', expectedMembersCount);
|
||||
cy.get('.cvat-organization-member-item-username').each((el) => {
|
||||
orgMembersUserameText.push(el.text());
|
||||
}).then(() => {
|
||||
expect(orgMembersUserameText).to.include.members(expectedOrganizationMembers);
|
||||
});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('inviteMembersToOrganization', (members) => {
|
||||
cy.get('.cvat-organization-top-bar-buttons-block').should('exist');
|
||||
cy.contains('button', 'Invite members').click();
|
||||
cy.get('.cvat-organization-invitation-modal').should('be.visible');
|
||||
let addedMembers = 0;
|
||||
for (const el of members) {
|
||||
cy.get('.cvat-organization-invitation-field-email')
|
||||
.last()
|
||||
.find('input')
|
||||
.type(el.email)
|
||||
.should('have.value', el.email);
|
||||
cy.get('.cvat-organization-invitation-field-email')
|
||||
.find('[aria-label="check-circle"]')
|
||||
.should('exist');
|
||||
cy.get('.cvat-organization-invitation-field-role').last().click();
|
||||
cy.get('.ant-select-dropdown')
|
||||
.should('be.visible')
|
||||
.not('.ant-select-dropdown-hidden')
|
||||
.find(`[title=${el.role}]`)
|
||||
.click();
|
||||
addedMembers++;
|
||||
if (addedMembers !== Object.keys(members).length) {
|
||||
cy.contains('button', 'Invite more').click();
|
||||
}
|
||||
}
|
||||
cy.get('.cvat-organization-invitation-modal')
|
||||
.contains('button', 'OK')
|
||||
.click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('removeMemberFromOrganization', (username) => {
|
||||
cy.contains('.cvat-organization-member-item-username', username)
|
||||
.parents('.cvat-organization-member-item')
|
||||
.find('.cvat-organization-member-item-remove')
|
||||
.click();
|
||||
cy.get('.cvat-modal-organization-member-remove')
|
||||
.contains('button', 'Yes, remove')
|
||||
.click();
|
||||
});
|
||||
Loading…
Reference in New Issue