Skip to content

Commit

Permalink
Cypress test. Canvas brightness contrast saturation feature (#2530)
Browse files Browse the repository at this point in the history
* add test

* change type variables, let to const

* change type another variables

* changed cssSelector to find cvat_canvas_background element

* change cssSelector from ant to cvat

Co-authored-by: Dmitriy Oparin <[email protected]>
  • Loading branch information
DmitriyOparin and Dmitriy Oparin authored Dec 11, 2020
1 parent 565020c commit 09cf807
Showing 1 changed file with 62 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

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

context('Canvas brightness/contrast/saturation feature', () => {
const caseId = '26';
const countActionMoveSlider = 10;
const defaultValueInSidebar = 100;
const expectedResultInSetting = defaultValueInSidebar + countActionMoveSlider;
const classNameSliders = [
'.cvat-player-settings-brightness',
'.cvat-player-settings-contrast',
'.cvat-player-settings-saturation',
];

function generateStringCountAction(countAction) {
let stringAction = '';
for (let i = 0; i < countAction; i++) {
stringAction += '{rightarrow}';
};
return stringAction;
};

function checkStateValuesInBackground(expectedValue) {
cy.get('#cvat_canvas_background')
.should('have.attr', 'style')
.and('contain', `filter: brightness(${expectedValue}) contrast(${expectedValue}) saturate(${expectedValue})`);
};

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

describe(`Testing case "${caseId}"`, () => {
it('Check apply of settings', () => {
let stringAction = generateStringCountAction(countActionMoveSlider);
cy.openSettings();
cy.get('.cvat-settings-modal').within(() => {
cy.contains('Player').click();
cy.wrap(classNameSliders).each(($el) => {
cy.wrap($el).get($el).within(() => {
cy.get('[role=slider]')
.type(stringAction)
.should('have.attr', 'aria-valuenow', expectedResultInSetting);
});
});
});
const expectedResultInBackground = (defaultValueInSidebar + countActionMoveSlider) / 100;
checkStateValuesInBackground(expectedResultInBackground);
});

it('Check reset of settings', () => {
cy.get('.cvat-player-reset-color-settings').click();
const expectedResultInBackground = defaultValueInSidebar / 100;
checkStateValuesInBackground(expectedResultInBackground);
});
});
});

0 comments on commit 09cf807

Please sign in to comment.