From d012c708a26aa0e4e43b6ebc8a1bf2e0835e0675 Mon Sep 17 00:00:00 2001
From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com>
Date: Fri, 23 Apr 2021 12:25:06 +0300
Subject: [PATCH] Cypress test. Import annotations for frames with dots in the
name. (#3111)
* Add css class
* Cypress test. Import annotations for frames with dots in name.
---
cvat-ui/src/reducers/notifications-reducer.ts | 1 +
..._import_annotations_frames_dots_in_name.js | 108 ++++++++++++++++++
2 files changed, 109 insertions(+)
create mode 100644 tests/cypress/integration/actions_tasks_objects/issue_2473_import_annotations_frames_dots_in_name.js
diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts
index bc56f3ffdba..497117be072 100644
--- a/cvat-ui/src/reducers/notifications-reducer.ts
+++ b/cvat-ui/src/reducers/notifications-reducer.ts
@@ -846,6 +846,7 @@ export default function (state = defaultState, action: AnyAction): Notifications
'Could not upload annotations for the ' +
`job ${taskID}`,
reason: error.toString(),
+ className: 'cvat-notification-notice-upload-annotations-fail',
},
},
},
diff --git a/tests/cypress/integration/actions_tasks_objects/issue_2473_import_annotations_frames_dots_in_name.js b/tests/cypress/integration/actions_tasks_objects/issue_2473_import_annotations_frames_dots_in_name.js
new file mode 100644
index 00000000000..dcfc1424f55
--- /dev/null
+++ b/tests/cypress/integration/actions_tasks_objects/issue_2473_import_annotations_frames_dots_in_name.js
@@ -0,0 +1,108 @@
+// Copyright (C) 2021 Intel Corporation
+//
+// SPDX-License-Identifier: MIT
+
+///
+
+context('Import annotations for frames with dots in name.', { browser: '!firefox' }, () => {
+ const issueId = '2473';
+ const labelName = `Issue ${issueId}`;
+ const taskName = labelName;
+ const attrName = `Attr for ${labelName}`;
+ const textDefaultValue = 'Some default value for type Text';
+ const imagesCount = 1;
+ const imageFileName = `image.${labelName.replace(' ', '_').toLowerCase()}`; // Dot in the image name
+ 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;
+
+ const createRectangleShape2Points = {
+ points: 'By 2 Points',
+ type: 'Shape',
+ labelName: labelName,
+ firstX: 250,
+ firstY: 350,
+ secondX: 350,
+ secondY: 450,
+ };
+
+ const dumpType = 'YOLO';
+ let annotationArchiveName = '';
+
+ function confirmUpdate(modalWindowClassName) {
+ cy.get(modalWindowClassName).within(() => {
+ cy.contains('button', 'Update').click();
+ });
+ }
+
+ 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.openTaskJob(taskName);
+ cy.createRectangle(createRectangleShape2Points);
+ });
+
+ after(() => {
+ cy.goToTaskList();
+ cy.deleteTask(taskName);
+ });
+
+ describe(`Testing case "${issueId}"`, () => {
+ it('Save job. Dump annotaion to YOLO format. Remove annotation. Save job.', () => {
+ cy.saveJob('PATCH', 200, 'saveJobDump');
+ cy.intercept('GET', '/api/v1/tasks/**/annotations**').as('dumpAnnotations');
+ cy.interactMenu('Dump annotations');
+ cy.get('.cvat-menu-dump-submenu-item').within(() => {
+ cy.contains(dumpType).click();
+ });
+ cy.wait('@dumpAnnotations', { timeout: 5000 }).its('response.statusCode').should('equal', 202);
+ cy.wait('@dumpAnnotations').its('response.statusCode').should('equal', 201);
+ cy.removeAnnotations();
+ cy.saveJob('PUT');
+ cy.get('#cvat_canvas_shape_1').should('not.exist');
+ cy.get('#cvat-objects-sidebar-state-item-1').should('not.exist');
+
+ cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
+ if (fileName.includes(dumpType.toLowerCase())) {
+ annotationArchiveName = fileName;
+ }
+ });
+ });
+
+ it('Upload annotation with YOLO format to job.', () => {
+ cy.interactMenu('Upload annotations');
+ cy.contains('.cvat-menu-load-submenu-item', dumpType.split(' ')[0])
+ .should('be.visible')
+ .within(() => {
+ cy.get('.cvat-menu-load-submenu-item-button')
+ .click()
+ .get('input[type=file]')
+ .attachFile(annotationArchiveName);
+ });
+ cy.intercept('PUT', '/api/v1/jobs/**/annotations**').as('uploadAnnotationsPut');
+ cy.intercept('GET', '/api/v1/jobs/**/annotations**').as('uploadAnnotationsGet');
+ confirmUpdate('.cvat-modal-content-load-job-annotation');
+ cy.wait('@uploadAnnotationsPut', { timeout: 5000 }).its('response.statusCode').should('equal', 202);
+ cy.wait('@uploadAnnotationsPut').its('response.statusCode').should('equal', 201);
+ cy.wait('@uploadAnnotationsGet').its('response.statusCode').should('equal', 200);
+ cy.get('.cvat-notification-notice-upload-annotations-fail').should('not.exist');
+ cy.get('#cvat_canvas_shape_1').should('exist');
+ cy.get('#cvat-objects-sidebar-state-item-1').should('exist');
+ });
+ });
+});