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 test. Repeat draw feature. #2887

Merged
Changes from 1 commit
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
@@ -0,0 +1,162 @@
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT

/// <reference types="cypress" />

import { taskName, labelName } from '../../support/const';

context('Repeat draw feature.', () => {
const caseId = '55';
const createRectangleShape2Points = {
points: 'By 2 Points',
type: 'Shape',
labelName: labelName,
firstX: 150,
firstY: 350,
secondX: 250,
secondY: 450,
};
const createCuboidShape2Points = {
points: 'From rectangle',
type: 'Shape',
labelName: labelName,
firstX: 300,
firstY: 350,
secondX: 400,
secondY: 450,
};
const createPolygonShape = {
redraw: false,
type: 'Shape',
labelName: labelName,
pointsMap: [
{ x: 450, y: 350 },
{ x: 550, y: 350 },
{ x: 550, y: 450 },
],
complete: true,
numberOfPoints: null,
};
const createPolylinesShape = {
type: 'Shape',
labelName: labelName,
pointsMap: [
{ x: 600, y: 350 },
{ x: 700, y: 350 },
{ x: 700, y: 450 },
],
complete: true,
numberOfPoints: null,
};
const createPointsShape = {
type: 'Shape',
labelName: labelName,
pointsMap: [{ x: 750, y: 400 }],
complete: true,
numberOfPoints: null,
};
const keyCodeN = 78;

before(() => {
cy.openTaskJob(taskName);
});

describe(`Testing case "${caseId}"`, () => {
it('Draw and repeat draw a rectangle.', () => {
cy.createRectangle(createRectangleShape2Points);
cy.get('.cvat-canvas-container').trigger('mousemove', 200, 400);
cy.get('#cvat_canvas_shape_1').should('have.class', 'cvat_canvas_shape_activated');
cy.get('body').trigger('keydown', { keyCode: keyCodeN });
cy.get('.cvat-canvas-container')
.click(createRectangleShape2Points.firstX, createRectangleShape2Points.firstY - 200)
.click(createRectangleShape2Points.secondX, createRectangleShape2Points.secondY - 200);
cy.get('#cvat_canvas_shape_2').should('exist');
cy.get('.cvat_canvas_shape').then(($shape) => {
expect($shape.length).to.be.equal(2);
});
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(2);
});
});

it('Draw and repeat draw a polygon.', () => {
cy.createPolygon(createPolygonShape);
cy.get('.cvat-canvas-container').trigger('mousemove', 520, 400);
cy.get('#cvat_canvas_shape_3').should('have.class', 'cvat_canvas_shape_activated');
cy.get('body').trigger('keydown', { keyCode: keyCodeN });
createPolygonShape.pointsMap.forEach((element) => {
cy.get('.cvat-canvas-container').click(element.x, element.y - 200);
});
cy.get('.cvat-canvas-container').trigger('keydown', { keyCode: keyCodeN }).trigger('keyup');
cy.get('#cvat_canvas_shape_4').should('exist');
cy.get('.cvat_canvas_shape').then(($shape) => {
expect($shape.length).to.be.equal(4);
});
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(4);
});
});

it('Draw and repeat draw a polyline.', () => {
cy.createPolyline(createPolylinesShape);
cy.get('.cvat-canvas-container').trigger('mousemove', 700, 400);
cy.get('#cvat_canvas_shape_5').should('have.class', 'cvat_canvas_shape_activated');
cy.get('body').trigger('keydown', { keyCode: keyCodeN });
createPolylinesShape.pointsMap.forEach((element) => {
cy.get('.cvat-canvas-container').click(element.x, element.y - 200);
});
cy.get('.cvat-canvas-container').trigger('keydown', { keyCode: keyCodeN }).trigger('keyup');
cy.get('#cvat_canvas_shape_6').should('exist');
bsekachev marked this conversation as resolved.
Show resolved Hide resolved
cy.get('.cvat_canvas_shape').then(($shape) => {
expect($shape.length).to.be.equal(6);
});
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(6);
});
Copy link
Member

Choose a reason for hiding this comment

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

One of these checks is extra IMHO

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed it. Left the object sidebar check

});

it('Draw and repeat draw a point.', () => {
cy.createPoint(createPointsShape);
cy.get('.cvat-canvas-container').trigger('mousemove', 750, 400);
Copy link
Member

Choose a reason for hiding this comment

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

As I see in points we do not check:

            cy.get('#cvat_canvas_shape_5').should('have.class', 'cvat_canvas_shape_activated');

Is it intented? Why do we need this mousemove in this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed the activation of the object before repeating the drawing

cy.get('body').trigger('keydown', { keyCode: keyCodeN });
createPointsShape.pointsMap.forEach((element) => {
cy.get('.cvat-canvas-container').click(element.x, element.y - 200);
});
cy.get('.cvat-canvas-container').trigger('keydown', { keyCode: keyCodeN }).trigger('keyup');
cy.get('#cvat_canvas_shape_8').should('exist');
cy.get('.cvat_canvas_shape').then(($shape) => {
expect($shape.length).to.be.equal(8);
});
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(8);
});
});

it('Draw and repeat draw a cuboid.', () => {
cy.createCuboid(createCuboidShape2Points);
cy.get('.cvat-canvas-container').trigger('mousemove', 300, 400);
cy.get('#cvat_canvas_shape_9').should('have.class', 'cvat_canvas_shape_activated');
cy.get('body').trigger('keydown', { keyCode: keyCodeN });
cy.get('.cvat-canvas-container')
.click(createCuboidShape2Points.firstX, createCuboidShape2Points.firstY - 200)
.click(createCuboidShape2Points.secondX, createCuboidShape2Points.secondY - 200);
cy.get('#cvat_canvas_shape_10').should('exist');
cy.get('.cvat_canvas_shape').then(($shape) => {
expect($shape.length).to.be.equal(10);
});
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(10);
});
});

it('Draw and repeat draw a tag.', () => {
cy.createTag(labelName);
cy.get('#cvat-objects-sidebar-state-item-11').trigger('keydown', { keyCode: keyCodeN });
cy.get('#cvat-objects-sidebar-state-item-12').should('exist');
cy.get('.cvat-objects-sidebar-state-item').then(($sidebarItem) => {
expect($sidebarItem.length).to.be.equal(12);
});
});
});
});