From 8f050d74374d6c21220dd838f00199f4459c9742 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Tue, 2 Mar 2021 12:16:22 +0300 Subject: [PATCH 1/3] Add css classes --- cvat-ui/src/components/actions-menu/actions-menu.tsx | 3 ++- cvat-ui/src/reducers/notifications-reducer.ts | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cvat-ui/src/components/actions-menu/actions-menu.tsx b/cvat-ui/src/components/actions-menu/actions-menu.tsx index ad7b6d55c88f..52e0f05bcb13 100644 --- a/cvat-ui/src/components/actions-menu/actions-menu.tsx +++ b/cvat-ui/src/components/actions-menu/actions-menu.tsx @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -66,6 +66,7 @@ export default function ActionsMenuComponent(props: Props): JSX.Element { Modal.confirm({ title: 'Current annotation will be lost', content: 'You are going to upload new annotations to this task. Continue?', + className: 'cvat-modal-content-load-task-annotation', onOk: () => { onClickMenu(copyParams, file); }, diff --git a/cvat-ui/src/reducers/notifications-reducer.ts b/cvat-ui/src/reducers/notifications-reducer.ts index 3bac02373db9..5451eba90020 100644 --- a/cvat-ui/src/reducers/notifications-reducer.ts +++ b/cvat-ui/src/reducers/notifications-reducer.ts @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -345,6 +345,7 @@ export default function (state = defaultState, action: AnyAction): Notifications 'Could not upload annotation for the ' + `task ${taskID}`, reason: action.payload.error.toString(), + className: 'cvat-notification-notice-load-annotation-failed', }, }, }, From 1adb5846b8f4389eb4315350c0ce82d59be2be51 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Tue, 2 Mar 2021 12:17:08 +0300 Subject: [PATCH 2/3] Update cypress test --- .../case_52_dump_upload_annotation.js | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js b/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js index e5d34b89f3b6..4609a66bcb91 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js +++ b/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js @@ -49,7 +49,7 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { }); }); - it('Upload annotation.', () => { + it('Upload annotation for job.', () => { cy.interactMenu('Upload annotations'); cy.contains('.cvat-menu-load-submenu-item', dumpType.split(' ')[0]) .should('be.visible') @@ -69,6 +69,28 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { cy.wait('@uploadAnnotationsGet').its('response.statusCode').should('equal', 200); cy.get('#cvat_canvas_shape_1').should('exist'); cy.get('#cvat-objects-sidebar-state-item-1').should('exist'); + cy.removeAnnotations(); + }); + + it('Upload annotation for task.', () => { + cy.goToTaskList(); + cy.contains('.cvat-item-task-name', taskName) + .parents('.cvat-tasks-list-item') + .find('.cvat-menu-icon') + .trigger('mouseover'); + cy.contains('Upload annotations').trigger('mouseover'); + 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.get('.cvat-modal-content-load-task-annotation').within(() => { + cy.contains('button', 'Update').click(); + }); + cy.contains('Annotations have been loaded').should('be.visible'); }); }); }); From b3fa78f2173dad34ab0de6a8350a1e766202a055 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Tue, 2 Mar 2021 13:21:33 +0300 Subject: [PATCH 3/3] Add negative scenario --- .../case_52_dump_upload_annotation.js | 92 ++++++++++++++----- 1 file changed, 71 insertions(+), 21 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js b/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js index 4609a66bcb91..ae1d9e01ba30 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js +++ b/tests/cypress/integration/actions_tasks_objects/case_52_dump_upload_annotation.js @@ -18,9 +18,47 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { secondY: 450, }; + const labelNameSecond = `Case ${caseId}`; + const taskNameSecond = `New annotation task for ${labelNameSecond}`; + const attrName = `Attr for ${labelNameSecond}`; + const textDefaultValue = 'Some default value for type Text'; + const imagesCount = 1; + const imageFileName = `image_${labelNameSecond.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; + const dumpType = 'CVAT for images'; let annotationArchiveName = ''; + function uploadToTask(toTaskName) { + cy.contains('.cvat-item-task-name', toTaskName) + .parents('.cvat-tasks-list-item') + .find('.cvat-menu-icon') + .trigger('mouseover'); + cy.contains('Upload annotations').trigger('mouseover'); + 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); + }); + } + + function confirmUpdate(modalWindowClassName) { + cy.get(modalWindowClassName).within(() => { + cy.contains('button', 'Update').click(); + }); + } + before(() => { cy.openTaskJob(taskName); cy.createRectangle(createRectangleTrack2Points); @@ -49,7 +87,7 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { }); }); - it('Upload annotation for job.', () => { + it('Upload annotation to job.', () => { cy.interactMenu('Upload annotations'); cy.contains('.cvat-menu-load-submenu-item', dumpType.split(' ')[0]) .should('be.visible') @@ -61,9 +99,7 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { }); cy.intercept('PUT', '/api/v1/jobs/**/annotations**').as('uploadAnnotationsPut'); cy.intercept('GET', '/api/v1/jobs/**/annotations**').as('uploadAnnotationsGet'); - cy.get('.cvat-modal-content-load-job-annotation').within(() => { - cy.contains('button', 'Update').click(); - }); + 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); @@ -72,25 +108,39 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => { cy.removeAnnotations(); }); - it('Upload annotation for task.', () => { + it('Upload annotation to task.', () => { cy.goToTaskList(); - cy.contains('.cvat-item-task-name', taskName) - .parents('.cvat-tasks-list-item') - .find('.cvat-menu-icon') - .trigger('mouseover'); - cy.contains('Upload annotations').trigger('mouseover'); - 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.get('.cvat-modal-content-load-task-annotation').within(() => { - cy.contains('button', 'Update').click(); - }); + uploadToTask(taskName); + confirmUpdate('.cvat-modal-content-load-task-annotation'); cy.contains('Annotations have been loaded').should('be.visible'); + cy.get('[data-icon="close"]').click(); + cy.openTaskJob(taskName, 0, false); + cy.get('#cvat_canvas_shape_1').should('exist'); + cy.get('#cvat-objects-sidebar-state-item-1').should('exist'); + }); + + it('Upload annotation to task which does not match the parameters. The error should be exist.', () => { + cy.goToTaskList(); + cy.imageGenerator( + imagesFolder, + imageFileName, + width, + height, + color, + posX, + posY, + labelNameSecond, + imagesCount, + ); + cy.createZipArchive(directoryToArchive, archivePath); + cy.createAnnotationTask(taskNameSecond, labelNameSecond, attrName, textDefaultValue, archiveName); + uploadToTask(taskNameSecond); + confirmUpdate('.cvat-modal-content-load-task-annotation'); + cy.get('.cvat-notification-notice-load-annotation-failed') + .should('exist') + .find('[aria-label="close"]') + .click(); + cy.deleteTask(taskNameSecond); }); }); });