Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/openvinotoolkit/cvat int…
Browse files Browse the repository at this point in the history
…o dkru/cypress-test-objects-ordering-feature
  • Loading branch information
Kruchinin committed Nov 27, 2020
2 parents 9e5eea2 + 6ef3ff2 commit e926973
Show file tree
Hide file tree
Showing 17 changed files with 331 additions and 32 deletions.
16 changes: 9 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,25 @@ before_install:
- nvm install ${NODE_VERSION}

before_script:
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml build
- chmod a+rwx ${HOST_COVERAGE_DATA_DIR}

script:
- if [[ $TRAVIS_EVENT_TYPE == "cron" && $TRAVIS_BRANCH == "develop" ]];
then
docker-compose -f docker-compose.yml -f ./tests/docker-compose.email.yml up -d --build;
docker exec -it cvat bash -ic 'python3 ~/manage.py migrate';
docker exec -it cvat bash -ic "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell";
cd ./tests && npm install && npm run cypress:run:firefox; exit $?;
fi;
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml build
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'coverage run -a manage.py test cvat/apps utils/cli && mv .coverage ${CONTAINER_COVERAGE_DATA_DIR}'
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd cvat-data && npm install && cd ../cvat-core && npm install && npm run test && mv ./reports/coverage/lcov.info ${CONTAINER_COVERAGE_DATA_DIR} && chmod a+rwx ${CONTAINER_COVERAGE_DATA_DIR}/lcov.info'
- docker-compose up -d
- docker exec -it cvat bash -ic "echo \"from django.contrib.auth.models import User; User.objects.create_superuser('${DJANGO_SU_NAME}', '${DJANGO_SU_EMAIL}', '${DJANGO_SU_PASSWORD}')\" | python3 ~/manage.py shell"
# End-to-end testing
- cd ./tests && npm install && cd ..
- if [[ $TRAVIS_EVENT_TYPE == "cron" && $TRAVIS_BRANCH == "develop" ]];
then
cd ./tests && npm run cypress:run:firefox && exit $?;
fi;
- npm install && npm run coverage
- docker-compose up -d --build
- cd ./tests && npx cypress run --headless --browser chrome
- cd ./tests && npm install && npx cypress run --headless --browser chrome
- mv ./.nyc_output ../ && cd ..
- npx nyc report --reporter=text-lcov >> ${HOST_COVERAGE_DATA_DIR}/lcov.info
- docker-compose -f docker-compose.yml -f docker-compose.ci.yml run cvat_ci /bin/bash -c 'cd ${CONTAINER_COVERAGE_DATA_DIR} && coveralls-lcov -v -n lcov.info > ${CONTAINER_COVERAGE_DATA_DIR}/coverage.json'
Expand Down
3 changes: 3 additions & 0 deletions tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Copyright (C) 2020 Intel Corporation
#
# SPDX-License-Identifier: MIT
3 changes: 2 additions & 1 deletion tests/cypress.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
"defaultCommandTimeout": 25000,
"env": {
"user": "admin",
"email": "admin@localhost.company",
"password": "12qwaszx"
},
"testFiles": [
"auth_page.js",
"actions_tasks_objects/*",
"actions_users/*",
"actions_users/**/*",
"actions_projects/*",
"remove_users_tasks_projects.js"
]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

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

context('Filters functionality.', () => {
const caseId = '18';
const labelShape = 'shape 3 points';
const additionalAttrsLabelShape = [
{ additionalAttrName: 'type', additionalValue: 'shape', typeAttribute: 'Text' },
{ additionalAttrName: 'count points', additionalValue: '3', typeAttribute: 'Text' },
{ additionalAttrName: 'polygon', additionalValue: 'True', typeAttribute: 'Checkbox' },
];
const labelTrack = 'track 4 points';
const additionalAttrsLabelTrack = [
{ additionalAttrName: 'type', additionalValue: 'track', typeAttribute: 'Text' },
{ additionalAttrName: 'polygon', additionalValue: 'True', typeAttribute: 'Checkbox' },
{ additionalAttrName: 'count points', additionalValue: '4', typeAttribute: 'Text' },
];

const createPolygonShape = {
reDraw: false,
type: 'Shape',
labelName: labelShape,
pointsMap: [
{ x: 200, y: 200 },
{ x: 250, y: 200 },
{ x: 250, y: 240 },
],
complete: true,
numberOfPoints: null,
};
const createRectangleTrack2Points = {
points: 'By 2 Points',
type: 'Track',
labelName: labelTrack,
firstX: 260,
firstY: 200,
secondX: 360,
secondY: 250,
};
const createRectangleShape4Points = {
points: 'By 4 Points',
type: 'Shape',
labelName: labelShape,
firstX: 550,
firstY: 350,
secondX: 650,
secondY: 350,
thirdX: 650,
thirdY: 450,
fourthX: 550,
fourthY: 450,
};
const createPolygonTrack = {
reDraw: false,
type: 'Track',
labelName: labelTrack,
pointsMap: [
{ x: 700, y: 350 },
{ x: 850, y: 350 },
{ x: 850, y: 450 },
{ x: 700, y: 450 },
],
numberOfPoints: 4,
};

let cvatCanvasShapeList = [];

function checkingFilterApplication(ids) {
for (let i = 0; i < cvatCanvasShapeList.length; i++) {
if (ids.indexOf(cvatCanvasShapeList[i]) > -1) {
cy.get(`#cvat_canvas_shape_${cvatCanvasShapeList[i]}`).should('exist');
cy.get(`#cvat-objects-sidebar-state-item-${cvatCanvasShapeList[i]}`).should('exist');
} else {
cy.get(`#cvat_canvas_shape_${cvatCanvasShapeList[i]}`).should('not.exist');
cy.get(`#cvat-objects-sidebar-state-item-${cvatCanvasShapeList[i]}`).should('not.exist');
}
}
}

before(() => {
cy.openTask(taskName);
cy.addNewLabel(labelShape, additionalAttrsLabelShape);
cy.addNewLabel(labelTrack, additionalAttrsLabelTrack);
cy.openJob();
});

describe(`Testing case "${caseId}"`, () => {
it('Draw several objects (different shapes, tracks, labels)', () => {
cy.createPolygon(createPolygonShape);
cy.createRectangle(createRectangleTrack2Points);
cy.createRectangle(createRectangleShape4Points);
cy.createPolygon(createPolygonTrack);
cy.get('.cvat_canvas_shape').then(($cvatCanvasShapeList) => {
for (let i = 0; i < $cvatCanvasShapeList.length; i++) {
cvatCanvasShapeList.push(Number($cvatCanvasShapeList[i].id.match(/\d+$/)));
}
});
});

it('Filter: shape=="polygon". Only the polygon exist.', () => {
cy.writeFilterValue(false, 'shape=="polygon"'); // #cvat_canvas_shape_1,4, #cvat-objects-sidebar-state-item-1,4
checkingFilterApplication([1, 4]);
});
it('Filter: shape=="polygon" | shape=="rectangle". Only the rectangle and polygon exist.', () => {
cy.writeFilterValue(true, 'shape=="polygon" | shape=="rectangle"'); // #cvat_canvas_shape_1,2,3,4, #cvat-objects-sidebar-state-item-1,2,3,4
checkingFilterApplication([1, 2, 3, 4]);
});
it('Filter: type=="shape". Only the objects with shape type exist.', () => {
cy.writeFilterValue(true, 'type=="shape"'); // #cvat_canvas_shape_1,3, #cvat-objects-sidebar-state-item-1,3
checkingFilterApplication([1, 3]);
});
it('Filter: label=="track 4 points". Only the polygon exist.', () => {
cy.writeFilterValue(true, `label=="${labelTrack}"`); // #cvat_canvas_shape_2,4, #cvat-objects-sidebar-state-item-2,4
checkingFilterApplication([2, 4]);
});
it('Filter: attr["count points"] == "4". Only the objects with same attr exist.', () => {
cy.writeFilterValue(true, 'attr["count points"] == "4"'); // #cvat_canvas_shape_2,4, #cvat-objects-sidebar-state-item-2,4
checkingFilterApplication([2, 4]);
});
it('Filter: width >= height. All objects exist.', () => {
cy.writeFilterValue(true, 'width >= height'); // #cvat_canvas_shape_1,2,3,4, #cvat-objects-sidebar-state-item-1,2,3,4
checkingFilterApplication([1, 2, 3, 4]);
});
it('Filter: clientID == 4. Only the objects with same id exist (polygon track).', () => {
cy.writeFilterValue(true, 'clientID == 4'); // #cvat_canvas_shape_7, #cvat-objects-sidebar-state-item-4
checkingFilterApplication([4]);
});
it('Filter: (label=="shape 3 points" & attr["polylines"]==true) | (label=="track 4 points" & width > 60). Only the objects polygon and rectangle exist.', () => {
cy.writeFilterValue(
true,
'(label=="shape 3 points" & attr["polylines"]==true) | (label=="track 4 points" & width > 60)',
); // #cvat_canvas_shape_2,4, #cvat-objects-sidebar-state-item-2,4
checkingFilterApplication([2, 4]);
});
it('Filter: (( label==["shape 3 points"]) | (attr["type"]=="shape" & width > 50)) & (height > 50 & (clientID == serverID))). All objects not exist.', () => {
cy.writeFilterValue(
true,
'(( label==["points shape"]) | (attr["type"]=="shape" & width > 50)) & (height > 50 & (clientID == serverID)))',
);
checkingFilterApplication([]);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { taskName, labelName } from '../../support/const';

context('Check error canvas is busy at resize element', () => {

const issueId = '1922';
const createRectangleShape2Points = {
points: 'By 2 Points',
Expand Down Expand Up @@ -43,9 +42,10 @@ context('Check error canvas is busy at resize element', () => {
const secondY = createRectangleShape2Points.secondY;
cy.get('.cvat-canvas-container')
.trigger('mousemove', secondX - 10, secondY - 10) // activate second shape
.trigger('mousedown', secondX, secondY, {button: 0})
.trigger('mousedown', secondX, secondY, { button: 0 })
.trigger('mousemove', secondX + 100, secondY + 100)
.get('body').type('d') // go to previous frame
.get('body')
.type('d') // go to previous frame
.trigger('mouseup');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,45 @@
/// <reference types="cypress" />

context('Issue 1599 (Chinese alphabet).', () => {
const firstName = '测试者';
const lastName = '测试';
const userName = 'Testuser_ch';
const email = 'Testuser_ch@local.local';
const password = 'Qwerty123!';

before(() => {
cy.visit('auth/register');
cy.url().should('include', '/auth/register');
});

describe('User registration using the Chinese alphabet.', () => {
it('Filling in the placeholder "First name"', () => {
cy.get('[placeholder="First name"]').type('测试者').should('not.have.class', 'has-error');
cy.get('[placeholder="First name"]').type(firstName).should('not.have.class', 'has-error');
});

it('Filling in the placeholder "Last name"', () => {
cy.get('[placeholder="Last name"]').type('测试').should('not.have.class', 'has-error');
cy.get('[placeholder="Last name"]').type(lastName).should('not.have.class', 'has-error');
});

it('Filling in the placeholder "Username"', () => {
cy.get('[placeholder="Username"]').type('Testuser_ch');
cy.get('[placeholder="Username"]').type(userName);
});

it('Filling in the placeholder "Email address"', () => {
cy.get('[placeholder="Email address"]').type('Testuser_ch@local.local');
cy.get('[placeholder="Email address"]').type(email);
});

it('Filling in the placeholder "Password"', () => {
cy.get('[placeholder="Password"]').type('Qwerty123!');
cy.get('[placeholder="Password"]').type(password);
});

it('Filling in the placeholder "Confirm password"', () => {
cy.get('[placeholder="Confirm password"]').type('Qwerty123!');
cy.get('[placeholder="Confirm password"]').type(password);
});

it('Click to "Submit" button', () => {
cy.get('[type="submit"]').click();
});

it('Successful registration', () => {
cy.url().should('include', '/tasks');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,34 +5,40 @@
/// <reference types="cypress" />

context('Issue 1599 (Polish alphabet).', () => {
const firstName = 'Świętobor';
const lastName = 'Сzcić';
const userName = 'Testuser_pl';
const email = 'Testuser_pl@local.local';
const password = 'Qwerty123!';

before(() => {
cy.visit('auth/register');
cy.url().should('include', '/auth/register');
});

describe('User registration using the Polish alphabet.', () => {
it('Filling in the placeholder "First name"', () => {
cy.get('[placeholder="First name"]').type('Świętobor').should('not.have.class', 'has-error');
cy.get('[placeholder="First name"]').type(firstName).should('not.have.class', 'has-error');
});

it('Filling in the placeholder "Last name"', () => {
cy.get('[placeholder="Last name"]').type('Сzcić').should('not.have.class', 'has-error');
cy.get('[placeholder="Last name"]').type(lastName).should('not.have.class', 'has-error');
});

it('Filling in the placeholder "Username"', () => {
cy.get('[placeholder="Username"]').type('Testuser_pl');
cy.get('[placeholder="Username"]').type(userName);
});

it('Filling in the placeholder "Email address"', () => {
cy.get('[placeholder="Email address"]').type('Testuser_pl@local.local');
cy.get('[placeholder="Email address"]').type(email);
});

it('Filling in the placeholder "Password"', () => {
cy.get('[placeholder="Password"]').type('Qwerty123!');
cy.get('[placeholder="Password"]').type(password);
});

it('Filling in the placeholder "Confirm password"', () => {
cy.get('[placeholder="Confirm password"]').type('Qwerty123!');
cy.get('[placeholder="Confirm password"]').type(password);
});

it('Click to "Submit" button', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (C) 2020 Intel Corporation
//
// SPDX-License-Identifier: MIT

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

const randomString = (isPassword) => {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
for (let i = 0; i <= 8; i++) {
result += characters.charAt(Math.floor(Math.random() * characters.length));
}
return isPassword ? `${result}${Math.floor(Math.random() * 10)}` : result;
};

context('Check email verification system', () => {
const caseId = 'Email verification system';
const firstName = `${randomString()}`;
const lastName = `${randomString()}`;
const userName = `${randomString()}`;
const emailAddr = `${userName}@local.local`;
const password = `${randomString(true)}`;

before(() => {
cy.visit('auth/register');
cy.url().should('include', '/auth/register');
});

describe(`Case: "${caseId}"`, () => {
it('Register user. Notification exist. The response status is successful.', () => {
cy.server().route('POST', '/api/v1/auth/register').as('userRegister');
cy.userRegistration(firstName, lastName, userName, emailAddr, password);
cy.get('.ant-notification-topRight')
.contains(`We have sent an email with a confirmation link to ${emailAddr}.`)
.should('exist');
cy.wait('@userRegister').its('status').should('eq', 201);
});
});
});
1 change: 1 addition & 0 deletions tests/cypress/integration/remove_users_tasks_projects.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ describe('Delete users and tasks created during the test run.', () => {
url: '/api/v1/auth/login',
body: {
username: Cypress.env('user'),
email: Cypress.env('email'),
password: Cypress.env('password'),
},
}).then(async (responce) => {
Expand Down
Loading

0 comments on commit e926973

Please sign in to comment.