Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cypress. Remove annotation before spec if an object exist. #2787

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -56,11 +56,6 @@ context('Label constructor. Color label.', () => {
cy.openTask(taskName);
});

after('Remove annotation and save job.', () => {
cy.removeAnnotations();
cy.saveJob('PUT');
});

describe(`Testing case "${caseId}"`, () => {
it('To add multiple labels with a color change.', () => {
cy.addNewLabel(colorRed, labelAdditionalAttrs, labelColor.redHex);
Expand Down Expand Up @@ -117,7 +112,7 @@ context('Label constructor. Color label.', () => {
});

it('Open the job. Existing objects with this label have changed their color.', () => {
cy.openJob();
cy.openJob(0, false);
cy.getObjectIdNumberByLabelName(colorRed).then((objectId) => {
cy.get(`#cvat_canvas_shape_${objectId}`).should('have.attr', 'stroke', `#${labelColor.yellowHex}`);
cy.get(`#cvat-objects-sidebar-state-item-${objectId}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ context('Export as a dataset.', () => {
cy.saveJob();
});

after('Remove annotations and save job', () => {
cy.removeAnnotations();
cy.saveJob('PUT');
});

describe(`Testing case "${caseId}"`, () => {
it('Go to Menu. Press "Export as a dataset" -> "CVAT for images".', () => {
cy.server().route('GET', '/api/v1/tasks/**/dataset**').as('exportDataset');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -22,11 +22,6 @@ context('Dump annotation if cuboid created', () => {
cy.openTaskJob(taskName);
});

after('Go to task list', () => {
cy.removeAnnotations();
cy.saveJob('PUT');
});

describe(`Testing issue "${issueId}"`, () => {
it('Create a cuboid', () => {
cy.createCuboid(createCuboidShape2Points);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand All @@ -22,11 +22,6 @@ context('Check error сannot read property at saving job', () => {
cy.openTaskJob(taskName);
});

after('Remove annotations and save job', () => {
cy.removeAnnotations();
cy.saveJob('PUT');
});

describe(`Testing pr "${prId}"`, () => {
it('Create an object in first frame', () => {
cy.createRectangle(createRectangleShape2Points);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation
// Copyright (C) 2020-2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

Expand Down Expand Up @@ -189,7 +189,7 @@ context('Review pipeline feature', () => {

it('Second user login. Open the task, open the job and annotates it.', () => {
cy.login(secondUserName, secondUser.password);
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.createRectangle(createRectangleShape2PointsSecond);
for (let i = 1; i < 4; i++) {
cy.createRectangle(createRectangleShape2Points);
Expand Down Expand Up @@ -223,7 +223,7 @@ context('Review pipeline feature', () => {
});

it('Second user opens the job again, switches to standard mode and tried to change anything and save changes. The request will be rejected with 403 code.', () => {
cy.openJob();
cy.openJob(0, false);
cy.get('.cvat-workspace-selector').should('have.text', 'Review');
cy.changeWorkspace('Standard', labelName);
cy.createPoint(createPointsShape);
Expand All @@ -239,7 +239,7 @@ context('Review pipeline feature', () => {

it('The third user opens the job. Review mode is opened automatically.', () => {
cy.login(thirdUserName, thirdUser.password);
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.get('.cvat-workspace-selector').should('have.text', 'Review');
});

Expand Down Expand Up @@ -310,7 +310,7 @@ context('Review pipeline feature', () => {
});

it("Reopen the job. Change something there. Save work. That saving wasn't successful. The third user logout.", () => {
cy.openJob();
cy.openJob(0, false);
cy.createPoint(createPointsShapeSecond);
cy.saveJob('PATCH', 403);
cy.get('.cvat-notification-notice-save-annotations-failed')
Expand All @@ -324,7 +324,7 @@ context('Review pipeline feature', () => {

it('The second user login. Opens the job again. All issues are visible.', () => {
cy.login(secondUserName, secondUser.password);
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.get('.cvat-workspace-selector').should('have.text', 'Standard');
for (const j of [
customeIssueDescription,
Expand Down Expand Up @@ -426,15 +426,15 @@ context('Review pipeline feature', () => {

it('The third user login, opens the job, goes to menu, "Submit review" => "Review next" => Assign the first user => Submit.', () => {
cy.login(thirdUserName, thirdUser.password);
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.interactMenu('Submit the review');
cy.submitReview('Review next', Cypress.env('user'));
cy.get('.cvat-not-found').should('exist');
});
it('The third user logout. The first user login and opens the job, goes to menu, "Submit review" => Accept => Submit', () => {
cy.logout(thirdUserName);
cy.login();
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.interactMenu('Submit the review');
cy.submitReview('Accept');
cy.url().should('include', '/tasks');
Expand All @@ -443,13 +443,13 @@ context('Review pipeline feature', () => {
});

it("The first user can change annotations. The second users can't change annotations. For the third user the task is not visible.", () => {
cy.openJob();
cy.openJob(0, false);
cy.createPoint(createPointsShapeThird);
cy.saveJob();
cy.get('.cvat-notification-notice-save-annotations-failed').should('not.exist');
cy.logout();
cy.login(secondUserName, secondUser.password);
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.createPoint(createPointsShapeFourth);
cy.saveJob();
cy.get('.cvat-notification-notice-save-annotations-failed').should('exist');
Expand All @@ -463,7 +463,7 @@ context('Review pipeline feature', () => {

it('The first user opens the job and presses "Renew the job".', () => {
cy.login();
cy.openTaskJob(taskName);
cy.openTaskJob(taskName, 0, false);
cy.interactMenu('Renew the job');
cy.get('.cvat-modal-content-renew-job').within(() => {
cy.contains('button', 'Continue').click();
Expand All @@ -474,7 +474,7 @@ context('Review pipeline feature', () => {
});

it('The first user opens the job and presses "Finish the job".', () => {
cy.openJob();
cy.openJob(0, false);
cy.interactMenu('Finish the job');
cy.get('.cvat-modal-content-finish-job').within(() => {
cy.contains('button', 'Continue').click();
Expand Down
15 changes: 12 additions & 3 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,17 +124,26 @@ Cypress.Commands.add('getJobNum', (jobID) => {
});
});

Cypress.Commands.add('openJob', (jobID = 0) => {
Cypress.Commands.add('openJob', (jobID = 0, removeAnnotations = true) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just suggestion to make working with arguments possibly easier:

 Cypress.Commands.add('openJob', ({jobID, removeAnnotations} = {}) => { 
    const $jobID = jobID || 0;  // default value
    const $removeAnnotations = removeAnnotations || true; // default value

    ...
});

You can call the command in any ways:

cy.openJob();
cy.openJob({ removeAnnotations: false });
cy.openJob({ jobID: 0 });

and you do not have to remember order of arguments

Sure, it is more applicable when you have a lot of arguments.

cy.getJobNum(jobID).then(($job) => {
cy.get('.cvat-task-jobs-table-row').contains('a', `Job #${$job}`).click();
});
cy.url().should('include', '/jobs');
cy.get('.cvat-canvas-container').should('exist');
if (removeAnnotations) {
cy.document().then((doc) => {
const objects = Array.from(doc.querySelectorAll('.cvat_canvas_shape'));
if (typeof objects !== 'undefined' && objects.length > 0) {
cy.removeAnnotations();
cy.saveJob('PUT');
}
});
}
});

Cypress.Commands.add('openTaskJob', (taskName, jobID = 0) => {
Cypress.Commands.add('openTaskJob', (taskName, jobID = 0, removeAnnotations = true) => {
cy.openTask(taskName);
cy.openJob(jobID);
cy.openJob(jobID, removeAnnotations);
});

Cypress.Commands.add('createRectangle', (createRectangleParams) => {
Expand Down