From 5c21adcc4ed843e1ff38801ee7e0ba8b358fed97 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Wed, 25 Nov 2020 13:45:44 +0300 Subject: [PATCH 1/3] add test --- ..._2174_reset_zoom_in_tag_annotation_mode.js | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js diff --git a/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js new file mode 100644 index 00000000..73a237fc --- /dev/null +++ b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js @@ -0,0 +1,56 @@ +// Copyright (C) 2020 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +import { taskName, labelName } from '../../support/const'; + +context('Reset zoom in tag annotation', () => { + const issueId = '2174'; + let scaleBefore = 0; + let scaleAfter = 0; + + before(() => { + cy.openTaskJob(taskName); + }); + + describe(`Testing issue "${issueId}"`, () => { + it('Uncheck reset zoom', () => { + cy.openSettings(); + cy.get('.ant-modal-content').within(() => { + cy.contains('Player').click(); + cy.get('.cvat-player-settings-reset-zoom-checkbox').within(() => { + cy.get('[type="checkbox"]').uncheck(); + }); + }); + cy.closeSettings(); + }); + + it('Go to tag annotation', () => { + cy.changeWorkspace('Tag annotation', labelName); + }); + + it('Change size background', () => { + cy.get('.cvat-canvas-container').trigger('wheel', { deltaY: 5 }); + }); + + it('Get scale from background', () => { + cy.get('#cvat_canvas_background') + .should('have.attr', 'style') + .then(($styles) => { + scaleBefore = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]); + }); + }); + + it('Check scale background on next frame', () => { + cy.get('.cvat-player-next-button').click(); + cy.get('#cvat_canvas_background') + .should('have.attr', 'style') + .then(($styles) => { + scaleAfter = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]); + cy.expect(scaleBefore).to.equal(scaleAfter); + }); + }); + }); +}); From 4dc442e0bc15a9cea19141a80deff98331a6ae9c Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Thu, 26 Nov 2020 15:40:33 +0300 Subject: [PATCH 2/3] improvements test --- ..._2174_reset_zoom_in_tag_annotation_mode.js | 86 +++++++++++++------ tests/cypress/support/commands.js | 8 ++ 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js index 73a237fc..471baa03 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js @@ -8,49 +8,81 @@ import { taskName, labelName } from '../../support/const'; context('Reset zoom in tag annotation', () => { const issueId = '2174'; - let scaleBefore = 0; - let scaleAfter = 0; + let scaleFirstFrame = 0; + let scaleSecondFrame = 0; + + function scaleFrame() { + cy.get('.cvat-canvas-container').trigger('wheel', { deltaY: 5 }); + }; + + function changeCheckboxResetZoom(value) { + cy.openSettings(); + cy.get('.ant-modal-content').within(() => { + cy.contains('Player').click(); + cy.get('.cvat-player-settings-reset-zoom-checkbox').within(() => { + if (value == "check") { + cy.get('[type="checkbox"]').check(); + } else if (value == "uncheck") { + cy.get('[type="checkbox"]').uncheck(); + }; + }); + }); + cy.closeSettings(); + }; + + function checkFrameNum(frameNum) { + cy.get('.cvat-player-frame-selector').within(() => { + cy.get('input[role="spinbutton"]').should('have.value', frameNum); + }); + }; before(() => { cy.openTaskJob(taskName); }); describe(`Testing issue "${issueId}"`, () => { - it('Uncheck reset zoom', () => { - cy.openSettings(); - cy.get('.ant-modal-content').within(() => { - cy.contains('Player').click(); - cy.get('.cvat-player-settings-reset-zoom-checkbox').within(() => { - cy.get('[type="checkbox"]').uncheck(); - }); - }); - cy.closeSettings(); + it('Set "reset zoom" to true', () => { + changeCheckboxResetZoom("check"); }); it('Go to tag annotation', () => { cy.changeWorkspace('Tag annotation', labelName); }); - it('Change size background', () => { - cy.get('.cvat-canvas-container').trigger('wheel', { deltaY: 5 }); + it('Scale frame', () => { + scaleFrame(); + cy.getScaleValue().then((value) => { + scaleFirstFrame = value; + }); }); - it('Get scale from background', () => { - cy.get('#cvat_canvas_background') - .should('have.attr', 'style') - .then(($styles) => { - scaleBefore = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]); - }); + it('Go to next frame and check reset scale on second frame', () => { + cy.get('.cvat-player-next-button').click(); + checkFrameNum(1); + cy.getScaleValue().then((value) => { + scaleSecondFrame = value; + expect(scaleFirstFrame).to.not.equal(scaleSecondFrame); + }); }); - it('Check scale background on next frame', () => { - cy.get('.cvat-player-next-button').click(); - cy.get('#cvat_canvas_background') - .should('have.attr', 'style') - .then(($styles) => { - scaleAfter = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]); - cy.expect(scaleBefore).to.equal(scaleAfter); - }); + it('Set "reset zoom" to false', () => { + changeCheckboxResetZoom("uncheck"); + }); + + it('Scale frame', () => { + scaleFrame(); + cy.getScaleValue().then((value) => { + scaleSecondFrame = value; + }); + }); + + it('Go to previous frame and check save scale on first frame', () => { + cy.get('.cvat-player-previous-button').click(); + checkFrameNum(0); + cy.getScaleValue().then((value) => { + scaleFirstFrame = value; + expect(scaleSecondFrame).to.equal(scaleFirstFrame); + }); }); }); }); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 340ce621..7e004088 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -422,3 +422,11 @@ Cypress.Commands.add('assignTaskToUser', (user) => { .contains(new RegExp(`^${user}$`, 'g')) .click(); }); + +Cypress.Commands.add('getScaleValue', () => { + cy.get('#cvat_canvas_background') + .should('have.attr', 'style') + .then(($styles) => { + return Number($styles.match(/scale\((\d\.\d+)\)/m)[1]); + }); +}); From acb53d952ffb56edacc39a5e6c9407b8868d2253 Mon Sep 17 00:00:00 2001 From: Dmitriy Oparin Date: Fri, 27 Nov 2020 10:29:04 +0300 Subject: [PATCH 3/3] added check scaleDefault --- .../issue_2174_reset_zoom_in_tag_annotation_mode.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js index 471baa03..febd82e4 100644 --- a/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js +++ b/tests/cypress/integration/actions_tasks_objects/issue_2174_reset_zoom_in_tag_annotation_mode.js @@ -10,6 +10,7 @@ context('Reset zoom in tag annotation', () => { const issueId = '2174'; let scaleFirstFrame = 0; let scaleSecondFrame = 0; + let scaleDefault = 0; function scaleFrame() { cy.get('.cvat-canvas-container').trigger('wheel', { deltaY: 5 }); @@ -50,6 +51,9 @@ context('Reset zoom in tag annotation', () => { }); it('Scale frame', () => { + cy.getScaleValue().then((value) => { + scaleDefault = value; + }); scaleFrame(); cy.getScaleValue().then((value) => { scaleFirstFrame = value; @@ -62,6 +66,7 @@ context('Reset zoom in tag annotation', () => { cy.getScaleValue().then((value) => { scaleSecondFrame = value; expect(scaleFirstFrame).to.not.equal(scaleSecondFrame); + expect(scaleDefault).to.equal(scaleSecondFrame); }); });