Cypress test. Drawing with predefined number points. (#2583)

* Cypress test. Drawing with predefined number of points.

* Updated version.

* Fix typo

* Add css class for modal window.

Rework cypress command for remove annotation.

Co-authored-by: Kruchinin <dmitryx.kruchinin@intel.com>
main
Dmitry Kruchinin 5 years ago committed by GitHub
parent 8285e8bdd1
commit 2c88e2ddb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -701,6 +701,7 @@ export default function (state = defaultState, action: AnyAction): Notifications
updating: {
message: 'Could not update annotations',
reason: action.payload.error.toString(),
className: 'cvat-notification-notice-update-annotations-failed',
},
},
},

@ -0,0 +1,113 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT
/// <reference types="cypress" />
import { taskName, labelName } from '../../support/const';
context('Drawing with predefined number of points.', () => {
const caseId = '34';
const countPointsPolygon = 3;
const countPointsPolyline = 2;
const countPointsPoint = 1;
const createPolygonShape = {
reDraw: false,
type: 'Shape',
labelName: labelName,
pointsMap: [
{ x: 500, y: 100 },
{ x: 600, y: 100 },
{ x: 500, y: 200 },
],
numberOfPoints: 3,
};
const createPolylinesShape = {
type: 'Shape',
labelName: labelName,
pointsMap: [
{ x: 500, y: 250 },
{ x: 600, y: 250 },
],
numberOfPoints: 2,
};
const createPointsShape = {
type: 'Shape',
labelName: labelName,
pointsMap: [{ x: 500, y: 200 }],
numberOfPoints: 1,
};
before(() => {
cy.openTaskJob(taskName);
});
function tryDrawObjectPredefinedNumberPoints(object, pointsCount) {
cy.get(`.cvat-draw-${object}-control`).click().wait(500);
cy.get('.cvat-draw-shape-popover')
.not('.ant-popover-hidden')
.within(() => {
cy.get('.cvat-draw-shape-popover-points-selector')
.type(`${pointsCount - 1}`)
.focused()
.tab();
cy.get('[role="spinbutton"]').should('have.attr', 'aria-valuenow', pointsCount);
});
}
function tryDeletePoint() {
let svgJsCircleId = [];
cy.get('#cvat_canvas_shape_1').trigger('mousemove').should('have.attr', 'fill-opacity', 0.3);
cy.get('circle').then((circle) => {
for (let i = 0; i < circle.length; i++) {
if (circle[i].id.match(/^SvgjsCircle\d+$/)) {
svgJsCircleId.push(circle[i].id);
}
}
cy.get(`#${svgJsCircleId[0]}`).click({ altKey: true });
});
}
function checkNotificationAndClose() {
cy.get('.cvat-notification-notice-update-annotations-failed')
.should('exist')
.within(() => {
cy.get('[aria-label="close"]').click();
});
}
describe(`Testing case "${caseId}"`, () => {
it('Start drawing a polygon. Set "Number of points" less then 3 and press Tab. "Number of points" takes the value 3 automatically.', () => {
tryDrawObjectPredefinedNumberPoints('polygon', countPointsPolygon);
});
it('Draw a polygon with 3 points. And try to delete one point. The error notification should appear.', () => {
cy.createPolygon(createPolygonShape);
tryDeletePoint();
checkNotificationAndClose();
cy.removeAnnotations(); // Removing the annotation for the convenience of further testing
});
it('Start drawing a polyline. Set "Number of points" less then 2 and press Tab. "Number of points" takes the value 2 automatically.', () => {
tryDrawObjectPredefinedNumberPoints('polyline', countPointsPolyline);
});
it('Draw a polyline with 2 points. And try to delete one point. The error notification should appear.', () => {
cy.createPolyline(createPolylinesShape);
tryDeletePoint();
checkNotificationAndClose();
cy.removeAnnotations(); // Removing the annotation for the convenience of further testing
});
it('Start drawing a point. Set "Number of points" less then 1 and press Tab. "Number of points" takes the value 1 automatically.', () => {
tryDrawObjectPredefinedNumberPoints('points', countPointsPoint);
});
it('Draw a point with 1 points. And try to delete one point. The error notification should appear.', () => {
cy.createPoint(createPointsShape);
tryDeletePoint();
checkNotificationAndClose();
});
});
});

@ -415,7 +415,7 @@ Cypress.Commands.add('advancedConfiguration', (advancedConfigurationParams) => {
});
Cypress.Commands.add('removeAnnotations', () => {
cy.get('.cvat-annotation-header-button').eq(0).click();
cy.contains('.cvat-annotation-header-button', 'Menu').click();
cy.get('.cvat-annotation-menu').within(() => {
cy.contains('Remove annotations').click();
});

@ -5,6 +5,7 @@
require('./commands');
require('./commands_projects');
require('@cypress/code-coverage/support');
require('cypress-plugin-tab');
before(() => {
if (Cypress.browser.family !== 'chromium') {

@ -1510,6 +1510,16 @@
"uri-js": "^4.2.2"
}
},
"ally.js": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/ally.js/-/ally.js-1.4.1.tgz",
"integrity": "sha1-n7fmuljvrE7pExyymqnuO1QLzx4=",
"dev": true,
"requires": {
"css.escape": "^1.5.0",
"platform": "1.3.3"
}
},
"ansi-escapes": {
"version": "3.2.0",
"resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-3.2.0.tgz",
@ -2737,6 +2747,12 @@
"randomfill": "^1.0.3"
}
},
"css.escape": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
"integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s=",
"dev": true
},
"cypress": {
"version": "5.3.0",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-5.3.0.tgz",
@ -2875,6 +2891,15 @@
"integrity": "sha512-ILj+3MJliP5p+wHyJaJoOfADu7vmjDg9OshMXJbqSzg3hTTjYU3X0/vANykbl5XmkOFa5G8Fl1RNSeBUu41KJQ==",
"dev": true
},
"cypress-plugin-tab": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/cypress-plugin-tab/-/cypress-plugin-tab-1.0.5.tgz",
"integrity": "sha512-QtTJcifOVwwbeMP3hsOzQOKf3EqKsLyjtg9ZAGlYDntrCRXrsQhe4ZQGIthRMRLKpnP6/tTk6G0gJ2sZUfRliQ==",
"dev": true,
"requires": {
"ally.js": "^1.4.1"
}
},
"dash-ast": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/dash-ast/-/dash-ast-1.0.0.tgz",
@ -5735,6 +5760,12 @@
"find-up": "^4.0.0"
}
},
"platform": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.3.tgz",
"integrity": "sha1-ZGx3ARiZhwtqCQPnXpl+jlHadGE=",
"dev": true
},
"pngjs": {
"version": "3.4.0",
"resolved": "https://registry.npmjs.org/pngjs/-/pngjs-3.4.0.tgz",

@ -7,6 +7,7 @@
"@cypress/code-coverage": "^3.8.1",
"cypress": "^5.0.0",
"cypress-file-upload": "^4.1.1",
"cypress-plugin-tab": "^1.0.5",
"cypress-localstorage-commands": "^1.3.1"
},
"dependencies": {

Loading…
Cancel
Save