Update Cypress test. Group features. (#2950)

* Update case 15. Added ungroup action.

* Reset grouping via type Esc.

* Add check fill attr

* Add ungroup via Shift+G

* Apply comments
main
Dmitry Kruchinin 5 years ago committed by GitHub
parent c9830d201e
commit 983e765fab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2020-2021 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -70,12 +70,20 @@ context('Group features', () => {
cy.saveLocalStorage(); cy.saveLocalStorage();
}); });
function groupObjects(objectsArray) { function testGroupObjects(objectsArray, cancelGrouping) {
cy.get('.cvat-group-control').click(); cy.get('.cvat-group-control').click();
for (const shapeToGroup of objectsArray) { for (const shapeToGroup of objectsArray) {
cy.get(shapeToGroup).click(); cy.get(shapeToGroup).click().should('have.class', 'cvat_canvas_shape_grouping');
} }
cancelGrouping ? cy.get('body').type('{Esc}') : cy.get('.cvat-group-control').click();
}
function testUnGroupObjects() {
cy.get('.cvat-group-control').click(); cy.get('.cvat-group-control').click();
for (const shapeToGroup of shapeArray) {
cy.get(shapeToGroup).click().should('have.class', 'cvat_canvas_shape_grouping');
}
cy.get('body').type('{Shift}g');
} }
function changeGroupColor(object, color) { function changeGroupColor(object, color) {
@ -91,6 +99,34 @@ context('Group features', () => {
cy.changeColorViaBadge(color); cy.changeColorViaBadge(color);
} }
function testShapesFillEquality(equal) {
for (const groupedShape of shapeArray) {
cy.get(groupedShape)
.should('have.css', 'fill')
.then(($shapesGroupColor) => {
if (equal) {
expect($shapesGroupColor).to.be.equal(defaultGroupColorRgb);
} else {
expect($shapesGroupColor).to.not.equal(defaultGroupColorRgb);
shapesGroupColor = $shapesGroupColor;
}
});
}
}
function testSidebarItemsBackgroundColorEquality() {
for (const objectSideBarShape of shapeSidebarItemArray) {
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(defaultGroupColorRgb.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(shapesGroupColor.match(/\d+, \d+, \d+/));
});
}
}
describe(`Testing case "${caseId}"`, () => { describe(`Testing case "${caseId}"`, () => {
it('Create two shapes and two tracks.', () => { it('Create two shapes and two tracks.', () => {
cy.createRectangle(createRectangleShape2Points); cy.createRectangle(createRectangleShape2Points);
@ -123,30 +159,25 @@ context('Group features', () => {
}); });
it('With group button unite two shapes. They have corresponding colors.', () => { it('With group button unite two shapes. They have corresponding colors.', () => {
groupObjects(shapeArray); testGroupObjects(shapeArray, true); // Reset grouping
for (const groupedShape of shapeArray) { testShapesFillEquality(true);
cy.get(groupedShape) testGroupObjects(shapeArray); // Group
.should('have.css', 'fill') testShapesFillEquality(false);
.then(($shapesGroupColor) => { testSidebarItemsBackgroundColorEquality();
// expected rgb(250, 50, 83) to not equal rgb(224, 224, 224) testUnGroupObjects(); // Ungroup
expect($shapesGroupColor).to.not.equal(defaultGroupColorRgb); testShapesFillEquality(true);
shapesGroupColor = $shapesGroupColor; // Start grouping. Cancel grouping via click to the same shape.
}); cy.get('.cvat-group-control').click();
} cy.get(shapeArray[0])
for (const objectSideBarShape of shapeSidebarItemArray) { .click()
cy.get(objectSideBarShape) .should('have.class', 'cvat_canvas_shape_grouping')
.should('have.css', 'background-color') .click()
.then(($bColorobjectSideBarShape) => { .should('not.have.class', 'cvat_canvas_shape_grouping');
// expected rgba(250, 50, 83, 0.533) to not include [ 224, 224, 224, index: 4, input: 'rgb(224, 224, 224)', groups: undefined ] cy.get('body').type('{Esc}'); // Cancel grouping
expect($bColorobjectSideBarShape).to.not.contain(defaultGroupColorRgb.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(shapesGroupColor.match(/\d+, \d+, \d+/));
});
}
}); });
it('With group button unite two track. They have corresponding colors.', () => { it('With group button unite two track. They have corresponding colors.', () => {
groupObjects(trackArray); testGroupObjects(trackArray);
for (const groupedTrack of trackArray) { for (const groupedTrack of trackArray) {
cy.get(groupedTrack) cy.get(groupedTrack)
.should('have.css', 'fill') .should('have.css', 'fill')
@ -195,7 +226,7 @@ context('Group features', () => {
}); });
} }
}); });
groupObjects(shapeArray); testGroupObjects(shapeArray);
}); });
it('Change group color.', () => { it('Change group color.', () => {

Loading…
Cancel
Save