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

Update cypress test. Image rotate. #2752

Merged
Merged
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 All @@ -8,6 +8,7 @@ import { taskName } from '../../support/const';

context('Check if the image is rotated', () => {
const caseId = '5';

function imageRotate(direction = 'anticlockwise') {
cy.get('.cvat-rotate-canvas-control').trigger('mouseover');
if (direction === 'clockwise') {
Expand All @@ -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(() => {
cy.openTaskJob(taskName);
});
Expand All @@ -25,34 +44,49 @@ context('Check if the image is rotated', () => {
it('Rotate image clockwise 90deg', () => {
imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);');
scaleFitImage();
});

it('Rotate image clockwise 180deg', () => {
imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);');
scaleFitImage();
});

it('Rotate image clockwise 270deg', () => {
imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);');
scaleFitImage();
});

it('Rotate image clockwise 360deg', () => {
imageRotate('clockwise');
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);');
scaleFitImage();
});

it('Rotate image anticlockwise 90deg', () => {
imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(270deg);');
scaleFitImage();
});

it('Rotate image anticlockwise 180deg', () => {
imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(180deg);');
scaleFitImage();
});

it('Rotate image anticlockwise 270deg', () => {
imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(90deg);');
scaleFitImage();
});

it('Rotate image anticlockwise 360deg', () => {
imageRotate();
cy.get('#cvat_canvas_background').should('have.attr', 'style').and('contain', 'rotate(0deg);');
scaleFitImage();
});
});
});