Update cypress test. Add scale/fit after an image rotate. (#2752)

main
Dmitry Kruchinin 5 years ago committed by GitHub
parent 3e9281942f
commit 71e2ddbb59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,4 +1,4 @@
// Copyright (C) 2020 Intel Corporation // Copyright (C) 2020-2021 Intel Corporation
// //
// SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
@ -8,6 +8,7 @@ import { taskName } from '../../support/const';
context('Check if the image is rotated', () => { context('Check if the image is rotated', () => {
const caseId = '5'; const caseId = '5';
function imageRotate(direction = 'anticlockwise') { function imageRotate(direction = 'anticlockwise') {
cy.get('.cvat-rotate-canvas-control').trigger('mouseover'); cy.get('.cvat-rotate-canvas-control').trigger('mouseover');
if (direction === 'clockwise') { if (direction === 'clockwise') {
@ -17,6 +18,24 @@ context('Check if the image is rotated', () => {
} }
} }
function scaleFitImage() {
let scaleBefore, scaleAfter;
cy.get('#cvat_canvas_background')
.should('have.attr', 'style')
.then(($styles) => {
scaleBefore = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]);
});
cy.get('.cvat-canvas-container').trigger('wheel', { deltaY: 5 });
cy.get('#cvat_canvas_background')
.should('have.attr', 'style')
.then(($styles) => {
scaleAfter = Number($styles.match(/scale\((\d\.\d+)\)/m)[1]);
cy.expect(scaleBefore).to.be.greaterThan(scaleAfter);
cy.get('#cvat_canvas_content').dblclick();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', scaleBefore);
});
}
before(() => { before(() => {
cy.openTaskJob(taskName); cy.openTaskJob(taskName);
}); });
@ -25,34 +44,49 @@ context('Check if the image is rotated', () => {
it('Rotate image clockwise 90deg', () => { it('Rotate image clockwise 90deg', () => {
imageRotate('clockwise'); imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);');
scaleFitImage();
}); });
it('Rotate image clockwise 180deg', () => { it('Rotate image clockwise 180deg', () => {
imageRotate('clockwise'); imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);');
scaleFitImage();
}); });
it('Rotate image clockwise 270deg', () => { it('Rotate image clockwise 270deg', () => {
imageRotate('clockwise'); imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);');
scaleFitImage();
}); });
it('Rotate image clockwise 360deg', () => { it('Rotate image clockwise 360deg', () => {
imageRotate('clockwise'); imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);');
scaleFitImage();
}); });
it('Rotate image anticlockwise 90deg', () => { it('Rotate image anticlockwise 90deg', () => {
imageRotate(); imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);');
scaleFitImage();
}); });
it('Rotate image anticlockwise 180deg', () => { it('Rotate image anticlockwise 180deg', () => {
imageRotate(); imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);');
scaleFitImage();
}); });
it('Rotate image anticlockwise 270deg', () => { it('Rotate image anticlockwise 270deg', () => {
imageRotate(); imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);');
scaleFitImage();
}); });
it('Rotate image anticlockwise 360deg', () => { it('Rotate image anticlockwise 360deg', () => {
imageRotate(); imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);'); cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);');
scaleFitImage();
}); });
}); });
}); });

Loading…
Cancel
Save