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

Added test for opacity reset #7207

Merged
merged 3 commits into from
Nov 30, 2023
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
134 changes: 134 additions & 0 deletions tests/cypress/e2e/issues_prs/issue_7176_opacity_reset.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// Copyright (C) 2023 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT

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

const issueId = '7176';

context('Opacity and Selected opacity reset on each frame change', { scrollBehavior: false }, () => {
const taskName = `Test issue #${issueId}`;
const serverFiles = ['images/image_1.jpg', 'images/image_2.jpg', 'images/image_3.jpg'];
const labelName = `issue#${issueId}`;
const createRectangleShape2Points = {
points: 'By 2 Points',
type: 'Shape',
labelName,
firstX: 100,
firstY: 350,
secondX: 200,
secondY: 450,
};
const drawingActions = [{
method: 'brush',
coordinates: [[300, 300], [700, 300], [700, 700], [300, 700]],
}];

let taskID = null;
let jobID = null;

function checkOpacitySliders(opacity, selectedOpacity) {
cy.get('.cvat-appearance-opacity-slider').find('[role="slider"]').should('have.attr', 'aria-valuenow', opacity);
cy.get('.cvat-appearance-selected-opacity-slider').find('[role="slider"]').should('have.attr', 'aria-valuenow', selectedOpacity);
}

function setSliderValue(slider, value) {
let arrowsString = '';
cy.get(slider)
.within(() => {
cy.get('[role="slider"]')
.should('have.attr', 'aria-valuenow')
.then(($ariaValueNow) => {
const steps = value - $ariaValueNow;
arrowsString = (steps > 0 ? '{rightarrow}' : '{leftarrow}').repeat(Math.abs(steps));
})
.then(() => {
cy.get('.ant-slider-handle').type(arrowsString);
});
});
}

before(() => {
cy.visit('auth/login');
cy.login();
cy.headlessCreateTask({
labels: [{ name: labelName, attributes: [], type: 'any' }],
name: taskName,
project_id: null,
source_storage: { location: 'local' },
target_storage: { location: 'local' },
}, {
server_files: serverFiles,
image_quality: 70,
use_zip_chunks: true,
use_cache: true,
sorting_method: 'lexicographical',
}).then((response) => {
taskID = response.taskID;
[jobID] = response.jobID;
}).then(() => {
cy.visit(`/tasks/${taskID}/jobs/${jobID}`);
cy.get('.cvat-canvas-container').should('exist').and('be.visible');
});

cy.goCheckFrameNumber(2);
cy.startMaskDrawing();
cy.drawMask(drawingActions);
cy.get('.cvat-brush-tools-finish').click();
});

after(() => {
cy.logout();
cy.getAuthKey().then((response) => {
const authKey = response.body.key;
cy.request({
method: 'DELETE',
url: `/api/tasks/${taskID}`,
headers: {
Authorization: `Token ${authKey}`,
},
});
});
});

describe(`Testing issue "${issueId}"`, () => {
it('Set low opacity value, draw a rectangle.', () => {
cy.goCheckFrameNumber(0);
setSliderValue('.cvat-appearance-opacity-slider', 20);
setSliderValue('.cvat-appearance-selected-opacity-slider', 40);
cy.createRectangle(createRectangleShape2Points);
checkOpacitySliders(20, 40);
});

it('Go to the next frame, draw a rectangle. Opacity does not reset', () => {
cy.goCheckFrameNumber(1);
cy.createRectangle(createRectangleShape2Points);
checkOpacitySliders(20, 40);
});

it('Go to the next frame with mask. Opacity resets.', () => {
cy.goCheckFrameNumber(2);
checkOpacitySliders(30, 60);
});

it('Decrease opacity. Opacity does not reset on frames without masks. Opacity resets on frames with masks', () => {
setSliderValue('.cvat-appearance-opacity-slider', 20);
setSliderValue('.cvat-appearance-selected-opacity-slider', 50);
cy.goCheckFrameNumber(0);
checkOpacitySliders(20, 50);
cy.goCheckFrameNumber(1);
checkOpacitySliders(20, 50);
cy.goCheckFrameNumber(2);
checkOpacitySliders(30, 60);
});

it('Increase opacity. Opacity does not reset on high values', () => {
setSliderValue('.cvat-appearance-opacity-slider', 40);
setSliderValue('.cvat-appearance-selected-opacity-slider', 70);
for (let i = 0; i < 3; i++) {
cy.goCheckFrameNumber(0);
checkOpacitySliders(40, 70);
}
});
});
});
Loading