From 5536b6de6e4a07291db1a4e18c32b66a8b4b8902 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Tue, 9 Feb 2021 13:01:17 +0300 Subject: [PATCH 1/2] Update cypress commands to remove anotation --- tests/cypress/support/commands.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 202a8b2b98c..b1af711e535 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -124,17 +124,26 @@ Cypress.Commands.add('getJobNum', (jobID) => { }); }); -Cypress.Commands.add('openJob', (jobID = 0) => { +Cypress.Commands.add('openJob', (jobID = 0, removeAnnotations = true) => { cy.getJobNum(jobID).then(($job) => { cy.get('.cvat-task-jobs-table-row').contains('a', `Job #${$job}`).click(); }); cy.url().should('include', '/jobs'); cy.get('.cvat-canvas-container').should('exist'); + if (removeAnnotations) { + cy.document().then((doc) => { + const objects = Array.from(doc.querySelectorAll('.cvat_canvas_shape')); + if (typeof objects !== 'undefined' && objects.length > 0) { + cy.removeAnnotations(); + cy.saveJob('PUT'); + } + }); + } }); -Cypress.Commands.add('openTaskJob', (taskName, jobID = 0) => { +Cypress.Commands.add('openTaskJob', (taskName, jobID = 0, removeAnnotations = true) => { cy.openTask(taskName); - cy.openJob(jobID); + cy.openJob(jobID, removeAnnotations); }); Cypress.Commands.add('createRectangle', (createRectangleParams) => { From f816f6096de0beb0d7637c579e3af68880ca1055 Mon Sep 17 00:00:00 2001 From: dvkruchinin Date: Tue, 9 Feb 2021 13:02:01 +0300 Subject: [PATCH 2/2] Update tests --- .../case_31_label_constructor_color_label.js | 9 ++----- .../case_47_export_dataset.js | 5 ---- .../issue_1568_cuboid_dump_annotation.js | 7 +----- ...rror_cannot_read_property_at_saving_job.js | 7 +----- .../case_28_review_pipeline_feature.js | 24 +++++++++---------- 5 files changed, 16 insertions(+), 36 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_31_label_constructor_color_label.js b/tests/cypress/integration/actions_tasks_objects/case_31_label_constructor_color_label.js index 94e4c1d9de8..b24169c7471 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_31_label_constructor_color_label.js +++ b/tests/cypress/integration/actions_tasks_objects/case_31_label_constructor_color_label.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -56,11 +56,6 @@ context('Label constructor. Color label.', () => { cy.openTask(taskName); }); - after('Remove annotation and save job.', () => { - cy.removeAnnotations(); - cy.saveJob('PUT'); - }); - describe(`Testing case "${caseId}"`, () => { it('To add multiple labels with a color change.', () => { cy.addNewLabel(colorRed, labelAdditionalAttrs, labelColor.redHex); @@ -117,7 +112,7 @@ context('Label constructor. Color label.', () => { }); it('Open the job. Existing objects with this label have changed their color.', () => { - cy.openJob(); + cy.openJob(0, false); cy.getObjectIdNumberByLabelName(colorRed).then((objectId) => { cy.get(`#cvat_canvas_shape_${objectId}`).should('have.attr', 'stroke', `#${labelColor.yellowHex}`); cy.get(`#cvat-objects-sidebar-state-item-${objectId}`) diff --git a/tests/cypress/integration/actions_tasks_objects/case_47_export_dataset.js b/tests/cypress/integration/actions_tasks_objects/case_47_export_dataset.js index c2fff01e2a2..e3ffcfbc825 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_47_export_dataset.js +++ b/tests/cypress/integration/actions_tasks_objects/case_47_export_dataset.js @@ -24,11 +24,6 @@ context('Export as a dataset.', () => { cy.saveJob(); }); - after('Remove annotations and save job', () => { - cy.removeAnnotations(); - cy.saveJob('PUT'); - }); - describe(`Testing case "${caseId}"`, () => { it('Go to Menu. Press "Export as a dataset" -> "CVAT for images".', () => { cy.server().route('GET', '/api/v1/tasks/**/dataset**').as('exportDataset'); diff --git a/tests/cypress/integration/actions_tasks_objects/issue_1568_cuboid_dump_annotation.js b/tests/cypress/integration/actions_tasks_objects/issue_1568_cuboid_dump_annotation.js index bae7864c778..bfc573b6b88 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_1568_cuboid_dump_annotation.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_1568_cuboid_dump_annotation.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -22,11 +22,6 @@ context('Dump annotation if cuboid created', () => { cy.openTaskJob(taskName); }); - after('Go to task list', () => { - cy.removeAnnotations(); - cy.saveJob('PUT'); - }); - describe(`Testing issue "${issueId}"`, () => { it('Create a cuboid', () => { cy.createCuboid(createCuboidShape2Points); diff --git a/tests/cypress/integration/actions_tasks_objects/pr_2203_error_cannot_read_property_at_saving_job.js b/tests/cypress/integration/actions_tasks_objects/pr_2203_error_cannot_read_property_at_saving_job.js index ab774f7ecda..480bd311390 100644 --- a/tests/cypress/integration/actions_tasks_objects/pr_2203_error_cannot_read_property_at_saving_job.js +++ b/tests/cypress/integration/actions_tasks_objects/pr_2203_error_cannot_read_property_at_saving_job.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -22,11 +22,6 @@ context('Check error сannot read property at saving job', () => { cy.openTaskJob(taskName); }); - after('Remove annotations and save job', () => { - cy.removeAnnotations(); - cy.saveJob('PUT'); - }); - describe(`Testing pr "${prId}"`, () => { it('Create an object in first frame', () => { cy.createRectangle(createRectangleShape2Points); diff --git a/tests/cypress/integration/actions_users/registration_involved/case_28_review_pipeline_feature.js b/tests/cypress/integration/actions_users/registration_involved/case_28_review_pipeline_feature.js index e50a1708057..3b41f569a58 100644 --- a/tests/cypress/integration/actions_users/registration_involved/case_28_review_pipeline_feature.js +++ b/tests/cypress/integration/actions_users/registration_involved/case_28_review_pipeline_feature.js @@ -1,4 +1,4 @@ -// Copyright (C) 2020 Intel Corporation +// Copyright (C) 2020-2021 Intel Corporation // // SPDX-License-Identifier: MIT @@ -189,7 +189,7 @@ context('Review pipeline feature', () => { it('Second user login. Open the task, open the job and annotates it.', () => { cy.login(secondUserName, secondUser.password); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.createRectangle(createRectangleShape2PointsSecond); for (let i = 1; i < 4; i++) { cy.createRectangle(createRectangleShape2Points); @@ -223,7 +223,7 @@ context('Review pipeline feature', () => { }); it('Second user opens the job again, switches to standard mode and tried to change anything and save changes. The request will be rejected with 403 code.', () => { - cy.openJob(); + cy.openJob(0, false); cy.get('.cvat-workspace-selector').should('have.text', 'Review'); cy.changeWorkspace('Standard', labelName); cy.createPoint(createPointsShape); @@ -239,7 +239,7 @@ context('Review pipeline feature', () => { it('The third user opens the job. Review mode is opened automatically.', () => { cy.login(thirdUserName, thirdUser.password); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.get('.cvat-workspace-selector').should('have.text', 'Review'); }); @@ -310,7 +310,7 @@ context('Review pipeline feature', () => { }); it("Reopen the job. Change something there. Save work. That saving wasn't successful. The third user logout.", () => { - cy.openJob(); + cy.openJob(0, false); cy.createPoint(createPointsShapeSecond); cy.saveJob('PATCH', 403); cy.get('.cvat-notification-notice-save-annotations-failed') @@ -324,7 +324,7 @@ context('Review pipeline feature', () => { it('The second user login. Opens the job again. All issues are visible.', () => { cy.login(secondUserName, secondUser.password); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.get('.cvat-workspace-selector').should('have.text', 'Standard'); for (const j of [ customeIssueDescription, @@ -426,7 +426,7 @@ context('Review pipeline feature', () => { it('The third user login, opens the job, goes to menu, "Submit review" => "Review next" => Assign the first user => Submit.', () => { cy.login(thirdUserName, thirdUser.password); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.interactMenu('Submit the review'); cy.submitReview('Review next', Cypress.env('user')); cy.get('.cvat-not-found').should('exist'); @@ -434,7 +434,7 @@ context('Review pipeline feature', () => { it('The third user logout. The first user login and opens the job, goes to menu, "Submit review" => Accept => Submit', () => { cy.logout(thirdUserName); cy.login(); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.interactMenu('Submit the review'); cy.submitReview('Accept'); cy.url().should('include', '/tasks'); @@ -443,13 +443,13 @@ context('Review pipeline feature', () => { }); it("The first user can change annotations. The second users can't change annotations. For the third user the task is not visible.", () => { - cy.openJob(); + cy.openJob(0, false); cy.createPoint(createPointsShapeThird); cy.saveJob(); cy.get('.cvat-notification-notice-save-annotations-failed').should('not.exist'); cy.logout(); cy.login(secondUserName, secondUser.password); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.createPoint(createPointsShapeFourth); cy.saveJob(); cy.get('.cvat-notification-notice-save-annotations-failed').should('exist'); @@ -463,7 +463,7 @@ context('Review pipeline feature', () => { it('The first user opens the job and presses "Renew the job".', () => { cy.login(); - cy.openTaskJob(taskName); + cy.openTaskJob(taskName, 0, false); cy.interactMenu('Renew the job'); cy.get('.cvat-modal-content-renew-job').within(() => { cy.contains('button', 'Continue').click(); @@ -474,7 +474,7 @@ context('Review pipeline feature', () => { }); it('The first user opens the job and presses "Finish the job".', () => { - cy.openJob(); + cy.openJob(0, false); cy.interactMenu('Finish the job'); cy.get('.cvat-modal-content-finish-job').within(() => { cy.contains('button', 'Continue').click();