Skip to content

Commit

Permalink
Cypress test. Collapse sidebar/apperance. (#2549)
Browse files Browse the repository at this point in the history
* add test

* add className for hide/unhide appearance

* change version cvat-ui

* change version cvat-ui

* step get value moved to before method

* small fix

* small improvements

Co-authored-by: Dmitriy Oparin <dmitriyx.oparin@intel.com>
  • Loading branch information
DmitriyOparin and Dmitriy Oparin authored Dec 21, 2020
1 parent 634e409 commit ca62b6b
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cvat-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion cvat-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "cvat-ui",
"version": "1.13.1",
"version": "1.13.2",
"description": "CVAT single-page application",
"main": "src/index.tsx",
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ function AppearanceBlock(props: Props): JSX.Element {
activeKey={appearanceCollapsed ? [] : ['appearance']}
className='cvat-objects-appearance-collapse'
>
<Collapse.Panel header={<Text strong>Appearance</Text>} key='appearance'>
<Collapse.Panel header={<Text strong className='cvat-objects-appearance-collapse-header'>Appearance</Text>} key='appearance'>
<div className='cvat-objects-appearance-content'>
<Text type='secondary'>Color by</Text>
<Radio.Group
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

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

context('Collapse sidebar/apperance', () => {
const caseId = '30';
let defaultValueLeftBackground;

function checkEqualBackground() {
cy.get('#cvat_canvas_background')
.should('have.css', 'left')
.and((currentValueLeftBackground) => {
currentValueLeftBackground = Number(currentValueLeftBackground.match(/\d+/));
expect(currentValueLeftBackground).to.be.eq(defaultValueLeftBackground);
});
}

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

// get default left value from background
cy.get('#cvat_canvas_background')
.should('have.css', 'left')
.then((currentValueLeftBackground) => {
defaultValueLeftBackground = Number(currentValueLeftBackground.match(/\d+/));
});
});

describe(`Testing case "${caseId}"`, () => {
it('Collapse sidebar', () => {
// hide
cy.get('.cvat-objects-sidebar-sider').click();
cy.get('.cvat-objects-sidebar').should('not.be.visible');
cy.get('#cvat_canvas_background')
.should('have.css', 'left')
.and((currentValueLeftBackground) => {
currentValueLeftBackground = Number(currentValueLeftBackground.match(/\d+/));
expect(currentValueLeftBackground).to.be.greaterThan(defaultValueLeftBackground);
});

// wait when background fitted
cy.wait(500);

// unhide
cy.get('.cvat-objects-sidebar-sider').click();
cy.get('.cvat-objects-sidebar').should('be.visible');
checkEqualBackground();
});

it('Collapse apperance', () => {
// hide
cy.get('.cvat-objects-appearance-collapse-header').click();
cy.get('.cvat-objects-appearance-content').should('not.be.visible');
checkEqualBackground();

// unhide
cy.get('.cvat-objects-appearance-collapse-header').click();
cy.get('.cvat-objects-appearance-content').should('be.visible');
checkEqualBackground();
});
});
});

0 comments on commit ca62b6b

Please sign in to comment.