From e773e6368943e0e9d76361888493fa7980de8cb8 Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Fri, 6 Nov 2020 11:18:01 +0300 Subject: [PATCH 1/4] Cypress test. Group features. --- .../case_15_group_features.js | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_15_group_features.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js new file mode 100644 index 00000000..6de93ef3 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js @@ -0,0 +1,132 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName } from '../../support/const'; + +context('Group features', () => { + const caseId = '15'; + const createRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + switchLabel: false, + firstX: 250, + firstY: 350, + secondX: 350, + secondY: 450, + }; + const createRectangleShape2PointsSecond = { + points: 'By 2 Points', + type: 'Shape', + switchLabel: false, + firstX: createRectangleShape2Points.firstX + 300, + firstY: createRectangleShape2Points.firstY, + secondX: createRectangleShape2Points.secondX + 300, + secondY: createRectangleShape2Points.secondY, + }; + const createRectangleTrack2Points = { + points: 'By 2 Points', + type: 'Track', + switchLabel: false, + firstX: 250, + firstY: 600, + secondX: 350, + secondY: 700, + }; + const createRectangleTrack2PointsSecond = { + points: 'By 2 Points', + type: 'Track', + switchLabel: false, + firstX: createRectangleTrack2Points.firstX + 300, + firstY: createRectangleTrack2Points.firstY, + secondX: createRectangleTrack2Points.secondX + 300, + secondY: createRectangleTrack2Points.secondY, + }; + + let fillChangeAppearance = ''; + let fillGroupedShape = ''; + let fillGroupedTrack = ''; + + before(() => { + cy.openTaskJob(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Create two shapes and two tracks.', () => { + cy.createRectangle(createRectangleShape2Points); + cy.createRectangle(createRectangleShape2PointsSecond); + cy.createRectangle(createRectangleTrack2Points); + cy.createRectangle(createRectangleTrack2PointsSecond); + }); + it('Set option "Color by" to "Group".', () => { + cy.changeAppearance('Group'); + cy.get('.cvat_canvas_shape').then($listCanvasShapes => { + for (let i=0; i<$listCanvasShapes.length; i++) { + cy.get($listCanvasShapes[i]).should('have.css', 'fill').then($fill => { + // expected rgb(224, 224, 224) to equal rgb(224, 224, 224) + expect($fill).to.be.equal($fill); + fillChangeAppearance = $fill; + }); + } + }); + cy.get('.cvat-objects-sidebar-state-item').then($listObjectsSidebarStateItem => { + for (let i=0; i<$listObjectsSidebarStateItem.length; i++) { + cy.get($listObjectsSidebarStateItem[i]).should('have.css', 'background-color').then($bColorObjectsSidebarStateItem => { + // expected rgba(224, 224, 224, 0.533) to include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] + expect($bColorObjectsSidebarStateItem).contain(fillChangeAppearance.match(/\d+, \d+, \d+/)) + }); + } + }); + }); + it('With group button unite two shapes. They have corresponding colors.', () => { + cy.get('.cvat-group-control').click(); + for (let shapeToGroup of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { + cy.get(shapeToGroup).click(); + } + cy.get('.cvat-group-control').click(); + for (let groupedShape of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { + cy.get(groupedShape).should('have.css', 'fill').then($fillGroupedShape => { + // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) + expect($fillGroupedShape).to.not.equal(fillChangeAppearance); + // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) + expect($fillGroupedShape).to.be.equal($fillGroupedShape); + fillGroupedShape = $fillGroupedShape; + }); + } + for (let objectSideBarShape of ['#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-2']) { + cy.get(objectSideBarShape).should('have.css', 'background-color').then($bColorobjectSideBarShape => { + // expected rgba(250, 50, 83, 0.533) to not include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] + expect($bColorobjectSideBarShape).to.not.contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); + // expected rgba(250, 50, 83, 0.533) to include [ 250, 50, 83, index: 4, input: 'rgb(250, 50, 83)', groups: undefined ] + expect($bColorobjectSideBarShape).to.be.contain(fillGroupedShape.match(/\d+, \d+, \d+/)); + }); + } + }); + it('With group button unite two track. They have corresponding colors.', () => { + cy.get('.cvat-group-control').click(); + for (let trackToGroup of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { + cy.get(trackToGroup).click(); + } + cy.get('.cvat-group-control').click(); + for (let groupedTrack of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { + cy.get(groupedTrack).should('have.css', 'fill').then($fillGroupedTrack => { + // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) + expect($fillGroupedTrack).to.not.equal(fillChangeAppearance); + // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) + expect($fillGroupedTrack).to.be.equal($fillGroupedTrack); + fillGroupedTrack = $fillGroupedTrack; + }); + } + for (let objectSideBarTrack of ['#cvat-objects-sidebar-state-item-3', '#cvat-objects-sidebar-state-item-4']) { + cy.get(objectSideBarTrack).should('have.css', 'background-color').then($bColorobjectSideBarTrack => { + // expected rgba(52, 209, 183, 0.533) to not include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] + expect($bColorobjectSideBarTrack).to.not.contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); + // expected rgba(52, 209, 183, 0.533) to include [ 52, 209, 183, index: 4, input: 'rgb(52, 209, 183)', groups: undefined ] + expect($bColorobjectSideBarTrack).to.be.contain(fillGroupedTrack.match(/\d+, \d+, \d+/)); + }); + } + }); + }); +}); From 9f11361ad06800b14cf4bd56664d8fe1f99a4155 Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Fri, 6 Nov 2020 11:34:06 +0300 Subject: [PATCH 2/4] Some fix. --- .../integration/actions_tasks_objects/case_15_group_features.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js index 6de93ef3..12fee478 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js +++ b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js @@ -75,7 +75,7 @@ context('Group features', () => { for (let i=0; i<$listObjectsSidebarStateItem.length; i++) { cy.get($listObjectsSidebarStateItem[i]).should('have.css', 'background-color').then($bColorObjectsSidebarStateItem => { // expected rgba(224, 224, 224, 0.533) to include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] - expect($bColorObjectsSidebarStateItem).contain(fillChangeAppearance.match(/\d+, \d+, \d+/)) + expect($bColorObjectsSidebarStateItem).contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); }); } }); From 7b3dee9ddb1ef25fbf8dd2b9369ada9521e5b772 Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Tue, 10 Nov 2020 22:09:02 +0300 Subject: [PATCH 3/4] Apply comments. --- .../case_15_group_features.js | 48 +++++++++---------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js index 12fee478..566878ee 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js +++ b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js @@ -45,9 +45,9 @@ context('Group features', () => { secondY: createRectangleTrack2Points.secondY, }; - let fillChangeAppearance = ''; - let fillGroupedShape = ''; - let fillGroupedTrack = ''; + let defaultGroupColor = ''; + let shapesGroupColor = ''; + let tracksGroupColor = ''; before(() => { cy.openTaskJob(taskName); @@ -65,9 +65,9 @@ context('Group features', () => { cy.get('.cvat_canvas_shape').then($listCanvasShapes => { for (let i=0; i<$listCanvasShapes.length; i++) { cy.get($listCanvasShapes[i]).should('have.css', 'fill').then($fill => { + defaultGroupColor = $fill; // expected rgb(224, 224, 224) to equal rgb(224, 224, 224) - expect($fill).to.be.equal($fill); - fillChangeAppearance = $fill; + expect(defaultGroupColor).to.be.equal($fill); }); } }); @@ -75,56 +75,56 @@ context('Group features', () => { for (let i=0; i<$listObjectsSidebarStateItem.length; i++) { cy.get($listObjectsSidebarStateItem[i]).should('have.css', 'background-color').then($bColorObjectsSidebarStateItem => { // expected rgba(224, 224, 224, 0.533) to include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] - expect($bColorObjectsSidebarStateItem).contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); + expect($bColorObjectsSidebarStateItem).contain(defaultGroupColor.match(/\d+, \d+, \d+/)); }); } }); }); it('With group button unite two shapes. They have corresponding colors.', () => { cy.get('.cvat-group-control').click(); - for (let shapeToGroup of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { + for (const shapeToGroup of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { cy.get(shapeToGroup).click(); } cy.get('.cvat-group-control').click(); - for (let groupedShape of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { - cy.get(groupedShape).should('have.css', 'fill').then($fillGroupedShape => { + for (const groupedShape of ['#cvat_canvas_shape_1', '#cvat_canvas_shape_2']) { + cy.get(groupedShape).should('have.css', 'fill').then($shapesGroupColor => { // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) - expect($fillGroupedShape).to.not.equal(fillChangeAppearance); + expect($shapesGroupColor).to.not.equal(defaultGroupColor); + shapesGroupColor = $shapesGroupColor; // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) - expect($fillGroupedShape).to.be.equal($fillGroupedShape); - fillGroupedShape = $fillGroupedShape; + expect(shapesGroupColor).to.be.equal($shapesGroupColor); }); } - for (let objectSideBarShape of ['#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-2']) { + for (const objectSideBarShape of ['#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-2']) { cy.get(objectSideBarShape).should('have.css', 'background-color').then($bColorobjectSideBarShape => { // expected rgba(250, 50, 83, 0.533) to not include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] - expect($bColorobjectSideBarShape).to.not.contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); + expect($bColorobjectSideBarShape).to.not.contain(defaultGroupColor.match(/\d+, \d+, \d+/)); // expected rgba(250, 50, 83, 0.533) to include [ 250, 50, 83, index: 4, input: 'rgb(250, 50, 83)', groups: undefined ] - expect($bColorobjectSideBarShape).to.be.contain(fillGroupedShape.match(/\d+, \d+, \d+/)); + expect($bColorobjectSideBarShape).to.be.contain(shapesGroupColor.match(/\d+, \d+, \d+/)); }); } }); it('With group button unite two track. They have corresponding colors.', () => { cy.get('.cvat-group-control').click(); - for (let trackToGroup of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { + for (const trackToGroup of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { cy.get(trackToGroup).click(); } cy.get('.cvat-group-control').click(); - for (let groupedTrack of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { - cy.get(groupedTrack).should('have.css', 'fill').then($fillGroupedTrack => { + for (const groupedTrack of ['#cvat_canvas_shape_3', '#cvat_canvas_shape_4']) { + cy.get(groupedTrack).should('have.css', 'fill').then($tracksGroupColor => { // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) - expect($fillGroupedTrack).to.not.equal(fillChangeAppearance); + expect($tracksGroupColor).to.not.equal(defaultGroupColor); + tracksGroupColor = $tracksGroupColor; // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) - expect($fillGroupedTrack).to.be.equal($fillGroupedTrack); - fillGroupedTrack = $fillGroupedTrack; + expect(tracksGroupColor).to.be.equal($tracksGroupColor); }); } - for (let objectSideBarTrack of ['#cvat-objects-sidebar-state-item-3', '#cvat-objects-sidebar-state-item-4']) { + for (const objectSideBarTrack of ['#cvat-objects-sidebar-state-item-3', '#cvat-objects-sidebar-state-item-4']) { cy.get(objectSideBarTrack).should('have.css', 'background-color').then($bColorobjectSideBarTrack => { // expected rgba(52, 209, 183, 0.533) to not include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] - expect($bColorobjectSideBarTrack).to.not.contain(fillChangeAppearance.match(/\d+, \d+, \d+/)); + expect($bColorobjectSideBarTrack).to.not.contain(defaultGroupColor.match(/\d+, \d+, \d+/)); // expected rgba(52, 209, 183, 0.533) to include [ 52, 209, 183, index: 4, input: 'rgb(52, 209, 183)', groups: undefined ] - expect($bColorobjectSideBarTrack).to.be.contain(fillGroupedTrack.match(/\d+, \d+, \d+/)); + expect($bColorobjectSideBarTrack).to.be.contain(tracksGroupColor.match(/\d+, \d+, \d+/)); }); } }); From 735786b06ad6bf4910564e00dae4b99be81ab643 Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Wed, 11 Nov 2020 08:21:47 +0300 Subject: [PATCH 4/4] Removal of unnecessary code --- .../actions_tasks_objects/case_15_group_features.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js index 566878ee..5b0bd1d0 100644 --- a/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js +++ b/tests/cypress/integration/actions_tasks_objects/case_15_group_features.js @@ -66,8 +66,6 @@ context('Group features', () => { for (let i=0; i<$listCanvasShapes.length; i++) { cy.get($listCanvasShapes[i]).should('have.css', 'fill').then($fill => { defaultGroupColor = $fill; - // expected rgb(224, 224, 224) to equal rgb(224, 224, 224) - expect(defaultGroupColor).to.be.equal($fill); }); } }); @@ -91,8 +89,6 @@ context('Group features', () => { // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) expect($shapesGroupColor).to.not.equal(defaultGroupColor); shapesGroupColor = $shapesGroupColor; - // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) - expect(shapesGroupColor).to.be.equal($shapesGroupColor); }); } for (const objectSideBarShape of ['#cvat-objects-sidebar-state-item-1', '#cvat-objects-sidebar-state-item-2']) { @@ -115,8 +111,6 @@ context('Group features', () => { // expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) expect($tracksGroupColor).to.not.equal(defaultGroupColor); tracksGroupColor = $tracksGroupColor; - // expected rgb(250, 50, 83) to equal rgb(250, 50, 83) - expect(tracksGroupColor).to.be.equal($tracksGroupColor); }); } for (const objectSideBarTrack of ['#cvat-objects-sidebar-state-item-3', '#cvat-objects-sidebar-state-item-4']) {