Skip to content

Commit

Permalink
Merge pull request #2493 from dvkruchinin/dkru/cypress-test-objects-o…
Browse files Browse the repository at this point in the history
…rdering-feature

Cypress test. Objects ordering feature.
  • Loading branch information
Boris Sekachev authored Nov 27, 2020
2 parents 9b8db7b + a804bf7 commit c4662fa
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

import { taskName, labelName, attrName } from '../../support/const';

context('Objects ordering feature', () => {
const caseId = '20';

const createRectangleShape2Points = {
points: 'By 2 Points',
type: 'Shape',
labelName: labelName,
firstX: 250,
firstY: 350,
secondX: 350,
secondY: 450,
};

const createRectangleShape2PointsSecond = {
points: 'By 2 Points',
type: 'Shape',
labelName: labelName,
firstX: createRectangleShape2Points.firstX + 300,
firstY: createRectangleShape2Points.firstY,
secondX: createRectangleShape2Points.secondX + 300,
secondY: createRectangleShape2Points.secondY,
};

function checkSideBarItemOrdering(ordering) {
let cvatObjectsSidebarStateItemIdList = [];
cy.get('.cvat-objects-sidebar-state-item').then(($cvatObjectsSidebarStateItemId) => {
for (let i = 0; i < $cvatObjectsSidebarStateItemId.length; i++) {
cvatObjectsSidebarStateItemIdList.push(Number($cvatObjectsSidebarStateItemId[i].id.match(/\d+$/)));
}
const idAscent = cvatObjectsSidebarStateItemIdList.reduce((previousValue, currentValue) => {
return previousValue > currentValue ? false : true;
});
if (ordering === 'ascent') {
expect(idAscent).to.be.true; //expected true to be true (ascent)
} else {
expect(idAscent).to.be.false; //expected false to be false (descent)
}
});
}

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

describe(`Testing case "${caseId}"`, () => {
it('Create a couple of shapes.', () => {
cy.createRectangle(createRectangleShape2Points);
cy.createRectangle(createRectangleShape2PointsSecond);
checkSideBarItemOrdering('ascent');
});

it('Sort object by "ID - descent".', () => {
cy.sidebarItemSortBy('ID - descent');
checkSideBarItemOrdering('descent');
});
it('Sort objects by "Updated time". Change something in the first object. This object now in the top', () => {
cy.sidebarItemSortBy('Updated time');
cy.get('#cvat_canvas_shape_1').trigger('mousemove').rightclick();
cy.get('.cvat-canvas-context-menu').within(() => {
cy.contains('.cvat-objects-sidebar-state-item-collapse', 'Details').click();
cy.contains('.cvat-object-item-attribute-wrapper', attrName).within(() => {
cy.get('.cvat-object-item-text-attribute').clear();
});
});
cy.get('.cvat-canvas-container').click(); // Hide context menu
checkSideBarItemOrdering('ascent');
});
});
});
8 changes: 8 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,14 @@ Cypress.Commands.add('createTag', (labelName) => {
});
});

Cypress.Commands.add('sidebarItemSortBy', (sortBy) => {
cy.get('.cvat-objects-sidebar-ordering-selector').click();
cy.get('.ant-select-dropdown')
.not('.ant-select-dropdown-hidden')
.contains(new RegExp(`^${sortBy}$`, 'g'))
.click();
});

Cypress.Commands.add('goToRegisterPage', () => {
cy.get('a[href="/auth/register"]').click();
cy.url().should('include', '/auth/register');
Expand Down

0 comments on commit c4662fa

Please sign in to comment.