From ab50c2cdd537a03f94b64d321d8b619234dd46fe Mon Sep 17 00:00:00 2001 From: Kruchinin Date: Fri, 30 Oct 2020 08:49:44 +0300 Subject: [PATCH] Cypress test for case 14. Appearance features. --- .../case_14_appearance_features.js | 93 +++++++++++++++++++ tests/cypress/support/commands.js | 2 +- 2 files changed, 94 insertions(+), 1 deletion(-) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_14_appearance_features.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_14_appearance_features.js b/tests/cypress/integration/actions_tasks_objects/case_14_appearance_features.js new file mode 100644 index 00000000..039b16f0 --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_14_appearance_features.js @@ -0,0 +1,93 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +import { taskName } from '../../support/const'; + +context('Appearance features', () => { + const caseId = '14'; + let ariaValuenow = 0; + const createRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + switchLabel: false, + firstX: 100, + firstY: 350, + secondX: 200, + secondY: 450, + }; + const createPolygonShape = { + reDraw: false, + type: 'Shape', + switchLabel: false, + pointsMap: [ + { x: 250, y: 350 }, + { x: 300, y: 300 }, + { x: 300, y: 450 }, + ], + complete: true, + numberOfPoints: null, + }; + const createPolylinesShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [ + { x: 350, y: 350 }, + { x: 400, y: 300 }, + { x: 400, y: 450 }, + { x: 350, y: 350 }, + ], + complete: true, + numberOfPoints: null, + }; + const createCuboidShape2Points = { + points: 'From rectangle', + type: 'Shape', + switchLabel: false, + firstX: 450, + firstY: 350, + secondX: 550, + secondY: 450, + }; + const createPointsShape = { + type: 'Shape', + switchLabel: false, + pointsMap: [{ x: 650, y: 350 }], + complete: true, + numberOfPoints: null, + }; + + before(() => { + cy.openTaskJob(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Create a rectangle, a polygon, a polyline, a cuboid and points.', () => { + cy.createRectangle(createRectangleShape2Points); + cy.createPolygon(createPolygonShape); + cy.createPolyline(createPolylinesShape); + cy.createCuboid(createCuboidShape2Points); + cy.createPoint(createPointsShape); + // Just in case, deactivate all objects + cy.get('.cvat-canvas-container').click('bottom'); + }); + it('Set opacity level for shapes to 100. All shapes are filled.', () => { + cy.get('.cvat-objects-appearance-content').within(() => { + cy.contains('Opacity').next().within(() => { + cy.get('.ant-slider-step').click('right'); + cy.get('[role="slider"]').should('have.attr', 'aria-valuemax').then(($ariaValuemax) => { + ariaValuenow = $ariaValuemax; + cy.get('[role="slider"]').should('have.attr', 'aria-valuenow', ariaValuenow); + }); + }); + }); + cy.get('.cvat_canvas_shape').each(object => { + cy.get(object).should('have.attr', 'fill-opacity', ariaValuenow / 100); + }); + }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 889551c4..27a104ce 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -228,13 +228,13 @@ Cypress.Commands.add('createCuboid', (createCuboidParams) => { if (createCuboidParams.switchLabel) { cy.switchLabel(createCuboidParams.labelName); } - cy.get('.cvat-draw-shape-popover-content').contains(createCuboidParams.points).click(); cy.contains('Draw new cuboid') .parents('.cvat-draw-shape-popover-content') .within(() => { cy.get('.ant-select-selection-selected-value').then(($labelValue) => { selectedValueGlobal = $labelValue.text(); }); + cy.contains(createCuboidParams.points).click(); cy.get('button').contains(createCuboidParams.type).click({ force: true }); }); cy.get('.cvat-canvas-container').click(createCuboidParams.firstX, createCuboidParams.firstY);