-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cypress tests. Paste labels to another task/project. (#4236)
* Start writing the test * Rename the test * Update the test. Added a cypress plugin * Added comment * Change the comment * Started writing the test for paste labels from another task * Added classes * Update command * Renamed fine name. Added test for task
- Loading branch information
Dmitry Kruchinin
authored
Jan 26, 2022
1 parent
e212d57
commit 5e43171
Showing
7 changed files
with
197 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ration/actions_projects_models/case_116_creating_project_by_inserting_labels_from_task.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
/// <reference types="cypress" /> | ||
|
||
// The test is disabled for Firefox because the "Cypress Real Events" plugin work only in the chromium-based browser. | ||
context('Creating a project by inserting labels from a task.', { browser: '!firefox' }, () => { | ||
const caseID = '116'; | ||
const task = { | ||
name: `Case ${caseID}`, | ||
label: 'Tree', | ||
attrName: 'Kind', | ||
attrValue: 'Oak', | ||
}; | ||
|
||
const projectName = `Case ${caseID}`; | ||
|
||
const imagesCount = 1; | ||
const imageFileName = `image_${task.name.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; | ||
|
||
before(() => { | ||
cy.visit('/'); | ||
cy.login(); | ||
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, task.name, imagesCount); | ||
cy.createZipArchive(directoryToArchive, archivePath); | ||
cy.goToTaskList(); | ||
cy.createAnnotationTask(task.name, task.label, task.attrName, task.attrValue, archiveName); | ||
}); | ||
|
||
after(() => { | ||
cy.logout(); | ||
cy.getAuthKey().then((authKey) => { | ||
cy.deleteTasks(authKey, [task.name]); | ||
cy.deleteProjects(authKey, [projectName]); | ||
}); | ||
}); | ||
|
||
describe(`Testing "Case ${caseID}"`, () => { | ||
it('Copying a labels from the task from the raw editor.', () => { | ||
cy.openTask(task.name); | ||
cy.contains('[role="tab"]', 'Raw').click(); | ||
cy.get('.cvat-raw-labels-viewer') | ||
.focus() | ||
.realPress(['ControlLeft', 'a']) | ||
.realPress(['ControlLeft', 'c']); | ||
}); | ||
|
||
it('Creating a project with copying labels from the task.', () => { | ||
cy.goToProjectsList(); | ||
cy.get('.cvat-create-project-button').click(); | ||
cy.get('#name').type(projectName); | ||
cy.contains('[role="tab"]', 'Raw').click(); | ||
cy.get('.cvat-raw-labels-viewer') | ||
.focus() | ||
.clear() | ||
.realPress(['ControlLeft', 'v']); | ||
cy.get('.cvat-raw-labels-viewer').then((raw) => { | ||
expect(raw.text()).not.contain('"id":'); | ||
}); | ||
cy.contains('button', 'Done').click(); | ||
cy.contains('[role="tab"]', 'Constructor').click(); | ||
cy.contains('.cvat-constructor-viewer-item', task.label).should('exist'); | ||
cy.contains('button', 'Submit').click(); | ||
cy.get('.cvat-notification-create-project-success').should('exist').find('[data-icon="close"]').click(); | ||
cy.goToProjectsList(); | ||
cy.openProject(projectName); | ||
cy.contains('[role="tab"]', 'Raw').click(); | ||
cy.get('.cvat-raw-labels-viewer').then((raw) => { | ||
expect(raw.text()).contain('"id":'); | ||
}); | ||
}); | ||
}); | ||
}); |
91 changes: 91 additions & 0 deletions
91
tests/cypress/integration/actions_tasks/case_117_paste_labels_from_another_task.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
// Copyright (C) 2022 Intel Corporation | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
/// <reference types="cypress" /> | ||
|
||
// The test is disabled for Firefox because the "Cypress Real Events" plugin work only in the chromium-based browser. | ||
context('Paste labels from one task to another.', { browser: '!firefox' }, () => { | ||
const caseID = '117'; | ||
const task = { | ||
name: `Case ${caseID}`, | ||
label: 'Tree', | ||
attrName: 'Kind', | ||
attrValue: 'Oak', | ||
nameSecond: `Case ${caseID} second`, | ||
labelSecond: 'Car', | ||
attrNameSecond: 'Color', | ||
attrValueSecond: 'Red', | ||
}; | ||
|
||
const imagesCount = 1; | ||
const imageFileName = `image_${task.name.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; | ||
|
||
before(() => { | ||
cy.visit('/'); | ||
cy.login(); | ||
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, task.name, imagesCount); | ||
cy.createZipArchive(directoryToArchive, archivePath); | ||
cy.goToTaskList(); | ||
cy.createAnnotationTask(task.name, task.label, task.attrName, task.attrValue, archiveName); | ||
cy.createAnnotationTask( | ||
task.nameSecond, task.labelSecond, task.attrNameSecond, task.attrValueSecond, archiveName, | ||
); | ||
}); | ||
|
||
after(() => { | ||
cy.logout(); | ||
cy.getAuthKey().then((authKey) => { | ||
cy.deleteTasks(authKey, [task.name, task.nameSecond]); | ||
}); | ||
}); | ||
|
||
describe(`Testing "Case ${caseID}"`, () => { | ||
it('Copying a label from a task via the raw editor.', () => { | ||
cy.openTask(task.name); | ||
cy.contains('[role="tab"]', 'Raw').click(); | ||
cy.get('.cvat-raw-labels-viewer') | ||
.focus() | ||
.realPress(['ControlLeft', 'a']) | ||
.realPress(['ControlLeft', 'c']); | ||
}); | ||
|
||
it('Paste the labels to another task instead of existing.', () => { | ||
cy.goToTaskList(); | ||
cy.openTask(task.nameSecond); | ||
cy.contains('.cvat-constructor-viewer-item', task.labelSecond).should('exist'); | ||
cy.contains('[role="tab"]', 'Raw').click(); | ||
cy.get('.cvat-raw-labels-viewer') | ||
.focus() | ||
.clear() | ||
.realPress(['ControlLeft', 'v']); | ||
cy.get('.cvat-raw-labels-viewer').then((raw) => { | ||
expect(raw.text()).not.contain('"id":'); | ||
}); | ||
cy.contains('button', 'Done').click(); | ||
cy.get('.cvat-modal-confirm-remove-existing-labels').should('be.visible').within(() => { | ||
cy.get('.cvat-modal-confirm-content-remove-existing-labels').should('have.text', task.labelSecond); | ||
cy.get('.cvat-modal-confirm-content-remove-existing-attributes') | ||
.should('have.text', task.attrNameSecond); | ||
cy.contains('button', 'Delete existing data').click(); | ||
}); | ||
cy.get('.cvat-modal-confirm-remove-existing-labels').should('not.exist'); | ||
cy.get('.cvat-raw-labels-viewer').then((raw) => { | ||
expect(raw.text()).contain('"id":'); | ||
}); | ||
cy.contains('[role="tab"]', 'Constructor').click(); | ||
cy.get('.cvat-constructor-viewer-item').should('have.length', 1); | ||
cy.contains('.cvat-constructor-viewer-item', task.label).should('exist'); | ||
cy.contains('.cvat-constructor-viewer-item', task.labelSecond).should('not.exist'); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters