Skip to content

Commit

Permalink
Cypress test. Create task without necessary arguments. (#2685)
Browse files Browse the repository at this point in the history
* Add the test.

* Add css classes.

* Add cypress test. Try to create a task without necessary arguments.

* Update copyright year

* Add step for deleting the task.

* Apply comments.

* Apply comments.
  • Loading branch information
dvkruchinin authored Jan 26, 2021
1 parent 165cf0f commit 23adfb6
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -86,6 +86,7 @@ class CreateTaskContent extends React.PureComponent<Props & RouteComponentProps,
notification.info({
message: 'The task has been created',
btn,
className: 'cvat-notification-create-task-success',
});

if (this.basicConfigurationComponent.current) {
Expand Down Expand Up @@ -149,6 +150,7 @@ class CreateTaskContent extends React.PureComponent<Props & RouteComponentProps,
notification.error({
message: 'Could not create a task',
description: 'A task must contain at least one label or belong to some project',
className: 'cvat-notification-create-task-fail',
});
return;
}
Expand All @@ -157,6 +159,7 @@ class CreateTaskContent extends React.PureComponent<Props & RouteComponentProps,
notification.error({
message: 'Could not create a task',
description: 'A task must contain at least one file',
className: 'cvat-notification-create-task-fail',
});
return;
}
Expand All @@ -179,6 +182,7 @@ class CreateTaskContent extends React.PureComponent<Props & RouteComponentProps,
notification.error({
message: 'Could not create a task',
description: error.toString(),
className: 'cvat-notification-create-task-fail',
});
});
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

context('Try to create a task without necessary arguments.', () => {
const caseId = '40';
const labelName = `Case ${caseId}`;
const taskName = `New annotation task for ${labelName}`;
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.get('#cvat-create-task-button').click();
});

after(() => {
cy.goToTaskList();
cy.getTaskID(taskName).then(($taskID) => {
cy.deleteTask(taskName, $taskID);
});
});

describe(`Testing "${labelName}"`, () => {
it('Try to create a task without any fields. A task is not created.', () => {
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('exist');
cy.closeNotification('.cvat-notification-create-task-fail');
});

it('Input a task name. A task is not created.', () => {
cy.get('[id="name"]').type(taskName);
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('exist');
cy.closeNotification('.cvat-notification-create-task-fail');
});

it('Input task labels. A task is not created.', () => {
cy.addNewLabel(labelName);
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('exist');
cy.closeNotification('.cvat-notification-create-task-fail');
});

it('Add some files. A task created.', () => {
cy.get('input[type="file"]').attachFile(archiveName, { subjectType: 'drag-n-drop' });
cy.get('.cvat-create-task-submit-section').click();
cy.get('.cvat-notification-create-task-fail').should('not.exist');
cy.get('.cvat-notification-create-task-success').should('exist');
// Check that the interface is prepared for creating the next task.
cy.get('[id="name"]').should('have.value', '');
cy.get('.cvat-constructor-viewer-item').should('not.exist');
});
});
});

0 comments on commit 23adfb6

Please sign in to comment.