From 92a26e00dd677f7dff074f69b879696e66d75266 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Fri, 6 Aug 2021 11:38:03 +0300 Subject: [PATCH] Cypress test. Create URL for a shape and frame. (#3516) * Cypress test. Installed module and cypress plugin * Updated the test. Experimtnts with a command * Try to getting a clipboard text * Rework adding clipboard. Revert index.js * Added the step for creation link for a frame. Added asserts * Adapted for Firefox --- .../case_102_create_link_shape_frame.js | 63 +++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks/case_102_create_link_shape_frame.js diff --git a/tests/cypress/integration/actions_tasks/case_102_create_link_shape_frame.js b/tests/cypress/integration/actions_tasks/case_102_create_link_shape_frame.js new file mode 100644 index 00000000..fe200323 --- /dev/null +++ b/tests/cypress/integration/actions_tasks/case_102_create_link_shape_frame.js @@ -0,0 +1,63 @@ +// Copyright (C) 2021 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName, labelName } from '../../support/const'; + +context('Create a link for shape, frame.', () => { + const caseId = '102'; + const createRectangleShape2Points = { + points: 'By 2 Points', + type: 'Shape', + labelName: labelName, + firstX: 250, + firstY: 350, + secondX: 350, + secondY: 450, + }; + + before(() => { + cy.openTaskJob(taskName); + cy.createRectangle(createRectangleShape2Points); + cy.saveJob('PATCH', 200, `case${caseId}`); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Create a link for a shape, for a frame.', () => { + cy.window().then(win => { + cy.stub(win, 'prompt').returns(win.prompt).as('copyToClipboardPromptShape'); + }); + cy.get('#cvat-objects-sidebar-state-item-1').find('[aria-label="more"]').trigger('mouseover'); + cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated') + cy.get('.cvat-object-item-menu').last().should('be.visible').contains('button', 'Create object URL').click(); + cy.get('@copyToClipboardPromptShape').should('be.called'); + cy.get('@copyToClipboardPromptShape').then(prompt => { + const url = prompt.args[0][1]; + expect(url).include('frame='); + expect(url).include('type='); + expect(url).include('serverID='); + cy.visit(url); + cy.closeModalUnsupportedPlatform(); + cy.get('.cvat-canvas-container').should('be.visible'); + cy.get('#cvat_canvas_shape_1').should('be.visible'); + }); + + cy.window().then(win => { + cy.stub(win, 'prompt').returns(win.prompt).as('copyToClipboardPromptFrame'); + }); + cy.get('.cvat-player-frame-url-icon').click(); + cy.get('@copyToClipboardPromptFrame').should('be.called'); + cy.get('@copyToClipboardPromptFrame').then(prompt => { + const url = prompt.args[0][1]; + expect(url).include('frame='); + expect(url).not.include('type='); + expect(url).not.include('serverID='); + cy.visit(url); + cy.get('.cvat-canvas-container').should('be.visible'); + cy.get('#cvat_canvas_shape_1').should('be.visible'); + }); + }); + }); +});