From 29e25abf19f878c45bc59c1cfba75412d665f458 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Mon, 30 Nov 2020 15:10:47 +0300 Subject: [PATCH] add test --- .../case_22_tag_annotation_mode.js | 81 +++++++++++++++++++ tests/cypress/support/commands.js | 14 ++++ 2 files changed, 95 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/case_22_tag_annotation_mode.js diff --git a/tests/cypress/integration/actions_tasks_objects/case_22_tag_annotation_mode.js b/tests/cypress/integration/actions_tasks_objects/case_22_tag_annotation_mode.js new file mode 100644 index 00000000..aaa69acb --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/case_22_tag_annotation_mode.js @@ -0,0 +1,81 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName, labelName } from '../../support/const'; + +context('Tag annotation mode.', () => { + const caseId = '22'; + + function checkCountFrameTags(countTags) { + cy.get('span.cvat-tag-anntation-sidebar-frame-tag-label').should('have.length', countTags); + }; + + function checkVisibleFrameTags(labelName) { + cy.get('.cvat-tag-anntation-sidebar-frame-tags').within(() => { + cy.get('span.cvat-tag-anntation-sidebar-frame-tag-label').contains(labelName).should('be.visible'); + }); + }; + + function addTag() { + cy.get('.cvat-tag-annotation-sidebar-buttons').contains('Add tag').click(); + }; + + function skipFrame() { + cy.get('.cvat-tag-annotation-sidebar-buttons').contains('Skip frame').click(); + }; + + function changeCheckboxAutomaticallyGoToNextFrame(value) { + cy.get('.cvat-tag-anntation-sidebar-checkbox-skip-frame').within(() => { + if (value == "check") { + cy.get('[type="checkbox"]').check(); + } else if (value == "uncheck") { + cy.get('[type="checkbox"]').uncheck(); + }; + }); + }; + + before(() => { + cy.openTaskJob(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('Go to tag annotation', () => { + cy.changeWorkspace('Tag annotation', labelName); + cy.checkFrameNum(0); + checkCountFrameTags(0); + }); + + it('Skip frame', () => { + skipFrame(); + cy.checkFrameNum(1); + checkCountFrameTags(0); + cy.goToPreviousFrame(); + cy.checkFrameNum(0); + checkCountFrameTags(0); + }); + + it('Add tag', () => { + addTag(); + cy.checkFrameNum(0); + checkCountFrameTags(1); + checkVisibleFrameTags(labelName); + }); + + it('Set "Automatically go to the next frame" to true and add tag', () => { + cy.goToNextFrame(); + cy.checkFrameNum(1); + checkCountFrameTags(0); + changeCheckboxAutomaticallyGoToNextFrame("check"); + addTag(); + cy.checkFrameNum(2); + checkCountFrameTags(0); + cy.goToPreviousFrame(); + cy.checkFrameNum(1); + checkCountFrameTags(1); + checkVisibleFrameTags(labelName); + }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 9648b333..0831a7a7 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -490,3 +490,17 @@ Cypress.Commands.add('writeFilterValue', (clear, filterValue) => { cy.get('.ant-select-selection__choice__content').should('have.text', filterValue); }); }); + +Cypress.Commands.add('checkFrameNum', (frameNum) => { + cy.get('.cvat-player-frame-selector').within(() => { + cy.get('input[role="spinbutton"]').should('have.value', frameNum); + }); +}); + +Cypress.Commands.add('goToNextFrame', () => { + cy.get('.cvat-player-next-button').click(); +}); + +Cypress.Commands.add('goToPreviousFrame', () => { + cy.get('.cvat-player-previous-button').click(); +});