Cypress/unit tests. Label deleting feature. (#2953)
* Add dummy second label * Add unit tests * Update cypress command * Add cypress tests * Revert command.js requare * Add css classes * Add css classmain
parent
eb1cb830bb
commit
c3fb14bf64
@ -0,0 +1,89 @@
|
|||||||
|
// Copyright (C) 2021 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
import { projectName, labelName } from '../../support/const_project';
|
||||||
|
|
||||||
|
context('Delete a label from a project.', () => {
|
||||||
|
const caseID = 57;
|
||||||
|
const taskName = `Task case ${caseID}`;
|
||||||
|
const attrName = `Attr for ${labelName}`;
|
||||||
|
const textDefaultValue = 'Some value for type Text';
|
||||||
|
const imagesCount = 1;
|
||||||
|
const imageFileName = `image_${taskName.replace(/\s+/g, '_').toLowerCase()}`;
|
||||||
|
const width = 800;
|
||||||
|
const height = 800;
|
||||||
|
const posX = 10;
|
||||||
|
const posY = 10;
|
||||||
|
const color = 'white';
|
||||||
|
const archiveName = `${imageFileName}.zip`;
|
||||||
|
const archivePath = `cypress/fixtures/${archiveName}`;
|
||||||
|
const imagesFolder = `cypress/fixtures/${imageFileName}`;
|
||||||
|
const directoryToArchive = imagesFolder;
|
||||||
|
const advancedConfigurationParams = false;
|
||||||
|
const forProject = true;
|
||||||
|
const attachToProject = false;
|
||||||
|
const multiAttrParams = false;
|
||||||
|
let projectID = '';
|
||||||
|
|
||||||
|
function getProjectID(projectName) {
|
||||||
|
cy.contains('.cvat-project-name', projectName)
|
||||||
|
.parents('.cvat-project-details')
|
||||||
|
.should('have.attr', 'cvat-project-id')
|
||||||
|
.then(($projectID) => {
|
||||||
|
projectID = $projectID;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
|
||||||
|
cy.createZipArchive(directoryToArchive, archivePath);
|
||||||
|
cy.openProject(projectName);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
cy.goToProjectsList();
|
||||||
|
cy.deleteProject(projectName, projectID);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(`Testing "Case ${caseID}"`, () => {
|
||||||
|
it('Create a task from project.', () => {
|
||||||
|
cy.createAnnotationTask(
|
||||||
|
taskName,
|
||||||
|
labelName,
|
||||||
|
attrName,
|
||||||
|
textDefaultValue,
|
||||||
|
archiveName,
|
||||||
|
multiAttrParams,
|
||||||
|
advancedConfigurationParams,
|
||||||
|
forProject,
|
||||||
|
attachToProject,
|
||||||
|
projectName,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Delete a label from project.', () => {
|
||||||
|
cy.openProject(projectName);
|
||||||
|
getProjectID(projectName);
|
||||||
|
cy.contains('.cvat-constructor-viewer-item', labelName)
|
||||||
|
.should('exist')
|
||||||
|
.and('be.visible')
|
||||||
|
.find('[aria-label="close"]')
|
||||||
|
.click();
|
||||||
|
cy.get('.cvat-modal-delete-label')
|
||||||
|
.should('be.visible')
|
||||||
|
.within(() => {
|
||||||
|
cy.contains('[type="button"]', 'OK').click();
|
||||||
|
});
|
||||||
|
cy.contains('.cvat-constructor-viewer-item', labelName).should('not.exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Try to open job with no labels in the project. Successful.', () => {
|
||||||
|
cy.openTaskJob(taskName);
|
||||||
|
cy.get('.cvat-disabled-canvas-control').should('exist');
|
||||||
|
cy.contains('.cvat-notification-no-labels', 'does not contain any label').should('exist').and('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
// Copyright (C) 2021 Intel Corporation
|
||||||
|
//
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Delete a label from a task.', () => {
|
||||||
|
const caseId = '58';
|
||||||
|
const labelName = `Case ${caseId}`;
|
||||||
|
const taskName = `New annotation task for ${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;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
cy.visit('auth/login');
|
||||||
|
cy.login();
|
||||||
|
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
|
||||||
|
cy.createZipArchive(directoryToArchive, archivePath);
|
||||||
|
cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName);
|
||||||
|
cy.openTask(taskName);
|
||||||
|
});
|
||||||
|
|
||||||
|
after(() => {
|
||||||
|
cy.goToTaskList();
|
||||||
|
cy.deleteTask(taskName);
|
||||||
|
});
|
||||||
|
|
||||||
|
describe(`Testing "${labelName}"`, () => {
|
||||||
|
it('Delete a label from the task.', () => {
|
||||||
|
cy.contains('.cvat-constructor-viewer-item', labelName)
|
||||||
|
.should('exist')
|
||||||
|
.and('be.visible')
|
||||||
|
.find('[aria-label="close"]')
|
||||||
|
.click();
|
||||||
|
cy.get('.cvat-modal-delete-label')
|
||||||
|
.should('be.visible')
|
||||||
|
.within(() => {
|
||||||
|
cy.contains('[type="button"]', 'OK').click();
|
||||||
|
});
|
||||||
|
cy.contains('.cvat-constructor-viewer-item', labelName).should('not.exist');
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Try to open a job with no labels. Successful.', () => {
|
||||||
|
cy.openJob();
|
||||||
|
cy.get('.cvat-disabled-canvas-control').should('exist');
|
||||||
|
cy.contains('.cvat-notification-no-labels', 'does not contain any label').should('exist').and('be.visible');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue