From 9190559396b9fc9cc60d1b4f8826f2006f4ed55f Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin <33020454+dvkruchinin@users.noreply.github.com> Date: Fri, 30 Apr 2021 19:20:30 +0300 Subject: [PATCH] Cypress test. Overlap size. (#3147) * Add css class * Add cyoress test. Update cypress command. * Add some checks --- cvat-ui/src/components/task-page/job-list.tsx | 2 +- .../actions_tasks/case_75_overlap_size.js | 88 +++++++++++++++++++ tests/cypress/support/commands.js | 4 + 3 files changed, 93 insertions(+), 1 deletion(-) create mode 100644 tests/cypress/integration/actions_tasks/case_75_overlap_size.js diff --git a/cvat-ui/src/components/task-page/job-list.tsx b/cvat-ui/src/components/task-page/job-list.tsx index 8a7cb460..7ce15b06 100644 --- a/cvat-ui/src/components/task-page/job-list.tsx +++ b/cvat-ui/src/components/task-page/job-list.tsx @@ -166,7 +166,7 @@ function JobListComponent(props: Props & RouteComponentProps): JSX.Element { title: 'Frames', dataIndex: 'frames', key: 'frames', - className: 'cvat-text-color', + className: 'cvat-text-color cvat-job-item-frames', }, { title: 'Status', diff --git a/tests/cypress/integration/actions_tasks/case_75_overlap_size.js b/tests/cypress/integration/actions_tasks/case_75_overlap_size.js new file mode 100644 index 00000000..44cfc8f6 --- /dev/null +++ b/tests/cypress/integration/actions_tasks/case_75_overlap_size.js @@ -0,0 +1,88 @@ +// Copyright (C) 2021 Intel Corporation +// +// SPDX-License-Identifier: MIT + +/// + +context('Overlap size.', () => { + const caseId = '75'; + const labelName = `Case ${caseId}`; + const taskName = labelName; + const attrName = `Attr for ${labelName}`; + const textDefaultValue = 'Some default value for type Text'; + const imagesCount = 10; + const imageFileName = `image_${labelName.replace(' ', '_').toLowerCase()}`; + const width = 800; + const height = 800; + const posX = 10; + const posY = 10; + const color = 'gray'; + const archiveName = `${imageFileName}.zip`; + const archivePath = `cypress/fixtures/${archiveName}`; + const imagesFolder = `cypress/fixtures/${imageFileName}`; + const directoryToArchive = imagesFolder; + const advancedConfigurationParams = { + multiJobs: true, + segmentSize: 5, + overlapSize: 3, + }; + const calculatedOverlapSize = advancedConfigurationParams.segmentSize - advancedConfigurationParams.overlapSize; + + before(() => { + cy.visit('auth/login'); + cy.login(); + cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount); + cy.createZipArchive(directoryToArchive, archivePath); + cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName, false, advancedConfigurationParams); + cy.openTask(taskName); + }); + + after(() => { + cy.goToTaskList(); + cy.deleteTask(taskName); + }); + + describe(`Testing case "${caseId}"`, () => { + it('The task parameters is correct.', () => { + cy.get('.cvat-task-parameters').within(() => { + cy.get('table').find('tr').last().find('td').then(($taskParameters) => { + expect(Number($taskParameters[0].innerText)).equal(calculatedOverlapSize); + expect(Number($taskParameters[1].innerText)).equal(advancedConfigurationParams.segmentSize); + }); + }); + }); + + it('The range of frame values corresponds to the parameters.', () => { + cy.getJobNum(0).then(($job) => { + cy.contains('a', `Job #${$job}`).parents('tr').find('.cvat-job-item-frames').then(($frameRange) => { + expect(Number($frameRange.text().split('-')[1])).equal(advancedConfigurationParams.segmentSize - 1); // expected 4 to equal 4 + }); + }); + cy.getJobNum(1).then(($job) => { + cy.contains('a', `Job #${$job}`).parents('tr').find('.cvat-job-item-frames').then(($frameRange) => { + expect(Number($frameRange.text().split('-')[0])).equal(advancedConfigurationParams.segmentSize - 2); // expected 3 to equal 3 + }); + }); + }); + + it('The range of frame values in a job corresponds to the parameters.', () => { + cy.openJob(0); + cy.get('.cvat-player-frame-selector') + .find('input[role="spinbutton"]') + .should('have.value', '0'); + cy.get('.cvat-player-last-button').click(); + cy.get('.cvat-player-frame-selector') + .find('input[role="spinbutton"]') + .should('have.value', advancedConfigurationParams.segmentSize - 1); // expected to have value '4' + cy.interactMenu('Open the task'); + cy.openJob(1); + cy.get('.cvat-player-frame-selector') + .find('input[role="spinbutton"]') + .should('have.value', advancedConfigurationParams.segmentSize - calculatedOverlapSize); // expected to have value '3' + cy.get('.cvat-player-last-button').click(); + cy.get('.cvat-player-frame-selector') + .find('input[role="spinbutton"]') + .should('have.value', advancedConfigurationParams.segmentSize + calculatedOverlapSize); // expected to have value '7' + }); + }); +}); diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index f75f13ad..c4f72075 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -485,6 +485,10 @@ Cypress.Commands.add('advancedConfiguration', (advancedConfigurationParams) => { if (advancedConfigurationParams.chunkSize) { cy.get('#dataChunkSize').type(advancedConfigurationParams.chunkSize); } + + if (advancedConfigurationParams.overlapSize) { + cy.get('#overlapSize').type(advancedConfigurationParams.overlapSize); + } }); Cypress.Commands.add('removeAnnotations', () => {