From 35b30d1fba5bcab57161a889579af3400d39f0f8 Mon Sep 17 00:00:00 2001 From: Dmitry Kruchinin Date: Wed, 19 Aug 2020 12:36:12 +0300 Subject: [PATCH] Cypress test for issue 1944 --- .../issue_1944_loading_screen_switch_job.js | 62 +++++++++++++++++++ tests/cypress/support/commands.js | 21 +++++-- 2 files changed, 78 insertions(+), 5 deletions(-) create mode 100644 tests/cypress/integration/issue_1944_loading_screen_switch_job.js diff --git a/tests/cypress/integration/issue_1944_loading_screen_switch_job.js b/tests/cypress/integration/issue_1944_loading_screen_switch_job.js new file mode 100644 index 000000000000..b68e1272e8cb --- /dev/null +++ b/tests/cypress/integration/issue_1944_loading_screen_switch_job.js @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2020 Intel Corporation + * + * SPDX-License-Identifier: MIT + */ + +/// + +context('Being able to return to the job list for a task and start a new job without an infinite loading screen.', () => { + + const issueId = '1944' + const labelName = `Issue ${issueId}` + const taskName = `New annotation task for ${labelName}` + const attrName = `Attr for ${labelName}` + const textDefaultValue = 'Some default value for type Text' + const imagesCount = 4 + let images = [] + for ( let i = 1; i <= imagesCount; i++) { + images.push(`image_${issueId}_${i}.png`) + } + const width = 800 + const height = 800 + const posX = 10 + const posY = 10 + const color = 'gray' + const archiveName = `images_issue_${issueId}.zip` + const archivePath = `cypress/fixtures/${archiveName}` + const imagesFolder = `cypress/fixtures/image_issue_${issueId}` + const directoryToArchive = imagesFolder + const multiJobs = true + + before(() => { + cy.visit('auth/login') + cy.login() + for (let img of images) { + cy.imageGenerator(imagesFolder, img, width, height, color, posX, posY, labelName) + } + cy.createZipArchive(directoryToArchive, archivePath) + }) + + describe(`Testing issue "${issueId}"`, () => { + it('Create a multijob task', () => { + cy.createAnnotationTask(taskName, labelName, attrName, textDefaultValue, archiveName, multiJobs) + }) + it('Open the task. Open first job', () => { + cy.openTaskJob(taskName) + cy.get('input[role="spinbutton"]') + .should('have.value', '0') + }) + it('Return to tasks page', () => { + cy.get('[value="tasks"]').click() + cy.url().should('include', '/tasks').and('not.contain', '/jobs') + }) + it('Open the task. Open second job', () => { + cy.openTaskJob(taskName, 1) + cy.get('.cvat-annotation-header') + .should('exist') + cy.get('input[role="spinbutton"]') + .should('have.value', '1') + }) + }) +}) diff --git a/tests/cypress/support/commands.js b/tests/cypress/support/commands.js index 80fab9671254..faf8e2d185fa 100644 --- a/tests/cypress/support/commands.js +++ b/tests/cypress/support/commands.js @@ -29,7 +29,9 @@ Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task', labelName='Some label', attrName='Some attr name', textDefaultValue='Some default value for type Text', - image='image.png') => { + image='image.png', + multiJobs=false, + segmentSize=1) => { cy.contains('button', 'Create new task').click() cy.url().should('include', '/tasks/create') cy.get('[id="name"]').type(taksName) @@ -42,6 +44,11 @@ Cypress.Commands.add('createAnnotationTask', (taksName='New annotation task', cy.get('[placeholder="Default value"]').type(textDefaultValue) cy.contains('button', 'Done').click() cy.get('input[type="file"]').attachFile(image, { subjectType: 'drag-n-drop' }); + if (multiJobs) { + cy.contains('Advanced configuration').click() + cy.get('#segmentSize') + .type(segmentSize) + } cy.contains('button', 'Submit').click() cy.contains('The task has been created', {timeout: '8000'}) cy.get('[value="tasks"]').click() @@ -55,14 +62,18 @@ Cypress.Commands.add('openTask', (taskName) => { .click() }) -Cypress.Commands.add('openJob', () => { - cy.contains('a', 'Job #').click() +Cypress.Commands.add('openJob', (jobNumber=0) => { + cy.get('.ant-table-tbody') + .find('tr') + .eq(jobNumber) + .contains('a', 'Job #') + .click() cy.url().should('include', '/jobs') }) -Cypress.Commands.add('openTaskJob', (taskName) => { +Cypress.Commands.add('openTaskJob', (taskName, jobNumber=0) => { cy.openTask(taskName) - cy.openJob() + cy.openJob(jobNumber) }) Cypress.Commands.add('createShape', (firstX, firstY, lastX, lastY) => {