未验证 提交 130b815f 编写于 作者: D Dmitry Kruchinin 提交者: GitHub

Cypress. Update the test for check issue 3810. (#3900)

* Add command for unpack zip

* Test adaptation

* Tests adaptation for tasks

* Fix ESLint issue for tests.

* Fix ESLint issue for cypress support/plugins

* Added tests folder to workspaces. Ignore Eslint isuue

* Fix deletingRegisteredUsers

* Update test for checking issue 3810

* Applying comments

* Removing tests from package.json workspaces.

* Adding nmp ci for tests folder
Co-authored-by: Ndvkruchinin <dvkruchinin@gmail.com>
上级 3dac403d
......@@ -22,6 +22,7 @@ jobs:
if [[ ! -z ${changed_files_eslint} ]]; then
npm ci
cd tests && npm ci && cd ..
npm install eslint-detailed-reporter --save-dev --legacy-peer-deps
mkdir -p eslint_report
......
......@@ -8,27 +8,35 @@ import { projectName, labelName } from '../../support/const_project';
context('Export project dataset.', { browser: '!firefox' }, () => {
const caseID = 103;
const taskName = `Task case ${caseID}`;
const attrName = `Attr for ${labelName}`;
const textDefaultValue = 'Some value for type Text';
const task = {
name: `Case ${caseID}`,
label: 'Tree',
attrName: 'Kind',
attrValue: 'Oak',
nameSecond: `Case ${caseID} second`,
labelSecond: 'Car',
attrNameSecons: 'Color',
attrValueSecond: 'Red',
multiAttrParams: false,
advancedConfigurationParams: false,
forProject: true,
attachToProject: false,
};
const imagesCount = 1;
const imageFileName = `image_${taskName.replace(/\s+/g, '_').toLowerCase()}`;
const imageFileName = `image_${task.name.replace(' ', '_').toLowerCase()}`;
const width = 800;
const height = 800;
const posX = 10;
const posY = 10;
const color = 'white';
const color = 'gray';
const archiveName = `${imageFileName}.zip`;
const archivePath = `cypress/fixtures/${archiveName}`;
const imagesFolder = `cypress/fixtures/${imageFileName}`;
const directoryToArchive = imagesFolder;
const advancedConfigurationParams = false;
const forProject = true;
const attachToProject = false;
const multiAttrParams = false;
let projectID = '';
function getProjectID(projectName) {
function getProjectID() {
cy.contains('.cvat-project-name', projectName)
.parents('.cvat-project-details')
.should('have.attr', 'cvat-project-id')
......@@ -37,11 +45,13 @@ context('Export project dataset.', { browser: '!firefox' }, () => {
});
}
function testCheckFile(file) {
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(file)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
}
function checkCounTasksInXML(projectParams, expectedCount) {
cy.exportProject(projectParams);
cy.waitForDownload();
cy.unpackZipArchive(`cypress/fixtures/${projectParams.archiveCustomeName}.zip`);
cy.readFile('cypress/fixtures/annotations.xml').should('exist').then((xml) => {
const tasks = Cypress.$(Cypress.$.parseXML(xml)).find('task').find('name');
expect(tasks.length).to.be.eq(expectedCount);
});
}
......@@ -49,17 +59,30 @@ context('Export project dataset.', { browser: '!firefox' }, () => {
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
cy.openProject(projectName);
getProjectID(projectName);
getProjectID();
cy.createAnnotationTask(
taskName,
labelName,
attrName,
textDefaultValue,
task.nameSecond,
task.labelSecond,
task.attrNameSecond,
task.attrValueSecond,
archiveName,
multiAttrParams,
advancedConfigurationParams,
forProject,
attachToProject,
task.multiAttrParams,
task.advancedConfigurationParams,
task.forProject,
task.attachToProject,
projectName,
);
cy.openProject(projectName);
cy.createAnnotationTask(
task.name,
task.label,
task.attrName,
task.attrValue,
archiveName,
task.multiAttrParams,
task.advancedConfigurationParams,
task.forProject,
task.attachToProject,
projectName,
);
});
......@@ -73,41 +96,42 @@ context('Export project dataset.', { browser: '!firefox' }, () => {
it('Export project dataset. Annotation.', () => {
cy.goToProjectsList();
const exportAnnotation = {
projectName: projectName,
projectName,
as: 'exportAnnotations',
type: 'annotations',
dumpType: 'CVAT for images',
};
cy.exportProject(exportAnnotation);
const regex = new RegExp(`^project_${projectName.toLowerCase()}-.*-${exportAnnotation.dumpType.toLowerCase()}.*.zip$`);
testCheckFile(regex);
cy.waitForDownload();
});
it('Export project dataset. Dataset.', () => {
cy.goToProjectsList();
const exportDataset = {
projectName: projectName,
projectName,
as: 'exportDataset',
type: 'dataset',
dumpType: 'CVAT for video',
};
cy.exportProject(exportDataset);
const regex = new RegExp(`^project_${projectName.toLowerCase()}-.*-${exportDataset.dumpType.toLowerCase()}.*.zip$`);
testCheckFile(regex);
cy.waitForDownload();
});
it('Export project dataset. Annotation. Rename a archive.', () => {
cy.goToProjectsList();
const exportAnnotationsRenameArchive = {
projectName: projectName,
projectName,
as: 'exportAnnotationsRenameArchive',
type: 'annotations',
dumpType: 'CVAT for images',
archiveCustomeName: 'export_project_annotation',
};
cy.exportProject(exportAnnotationsRenameArchive);
const regex = new RegExp(`^${exportAnnotationsRenameArchive.archiveCustomeName}.zip$`);
testCheckFile(regex);
// Check issue 3810
checkCounTasksInXML(exportAnnotationsRenameArchive, 2);
cy.openProject(projectName);
cy.deleteTask(task.nameSecond);
cy.goToProjectsList();
checkCounTasksInXML(exportAnnotationsRenameArchive, 1);
});
});
});
......@@ -21,7 +21,7 @@ context('Export project dataset with 3D task.', { browser: '!firefox' }, () => {
};
let projectID = '';
function getProjectID(projectName) {
function getProjectID() {
cy.contains('.cvat-project-name', projectName)
.parents('.cvat-project-details')
.should('have.attr', 'cvat-project-id')
......@@ -30,17 +30,9 @@ context('Export project dataset with 3D task.', { browser: '!firefox' }, () => {
});
}
function testCheckFile(file) {
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(file)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
}
});
}
before(() => {
cy.openProject(projectName);
getProjectID(projectName);
getProjectID();
cy.createAnnotationTask(
task.name3d,
task.label3d,
......@@ -64,41 +56,38 @@ context('Export project dataset with 3D task.', { browser: '!firefox' }, () => {
it('Export project with 3D task. Annotation.', () => {
cy.goToProjectsList();
const exportAnnotation3d = {
projectName: projectName,
projectName,
as: 'exportAnnotations3d',
type: 'annotations',
dumpType: 'Kitti Raw Format',
};
cy.exportProject(exportAnnotation3d);
const regex = new RegExp(`^project_${projectName.toLowerCase()}-.*-${exportAnnotation3d.dumpType.toLowerCase()}.*.zip$`);
testCheckFile(regex);
cy.waitForDownload();
});
it('Export project with 3D task. Dataset.', () => {
cy.goToProjectsList();
const exportDataset3d = {
projectName: projectName,
projectName,
as: 'exportDataset3d',
type: 'dataset',
dumpType: 'Sly Point Cloud Format',
};
cy.exportProject(exportDataset3d);
const regex = new RegExp(`^project_${projectName.toLowerCase()}-.*-${exportDataset3d.dumpType.toLowerCase()}.*.zip$`);
testCheckFile(regex);
cy.waitForDownload();
});
it('Export project with 3D task. Annotation. Rename a archive.', () => {
cy.goToProjectsList();
const exportAnnotations3dRenameArchive = {
projectName: projectName,
projectName,
as: 'exportAnnotations3dRenameArchive',
type: 'annotations',
dumpType: 'Kitti Raw Format',
archiveCustomeName: 'export_project_3d_annotation',
};
cy.exportProject(exportAnnotations3dRenameArchive);
const regex = new RegExp(`^${exportAnnotations3dRenameArchive.archiveCustomeName}.zip$`);
testCheckFile(regex);
cy.waitForDownload();
});
});
});
......@@ -11,7 +11,7 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => {
const createRectangleTrack2Points = {
points: 'By 2 Points',
type: 'Track',
labelName: labelName,
labelName,
firstX: 250,
firstY: 350,
secondX: 350,
......@@ -80,12 +80,9 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => {
archiveCustomeName: 'task_export_annotation_custome_name',
};
cy.exportTask(exportAnnotationRenameArchive);
const regex = new RegExp(`^${exportAnnotationRenameArchive.archiveCustomeName}.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationArchiveNameCustomeName = fileName;
}
cy.getDownloadFileName().then((file) => {
annotationArchiveNameCustomeName = file;
cy.verifyDownload(annotationArchiveNameCustomeName);
});
});
......@@ -96,19 +93,14 @@ context('Dump/Upload annotation.', { browser: '!firefox' }, () => {
format: exportFormat,
};
cy.exportTask(exportAnnotation);
cy.getDownloadFileName().then((file) => {
annotationArchiveName = file;
cy.verifyDownload(annotationArchiveName);
});
cy.removeAnnotations();
cy.saveJob('PUT');
cy.get('#cvat_canvas_shape_1').should('not.exist');
cy.get('#cvat-objects-sidebar-state-item-1').should('not.exist');
const regex = new RegExp(
`^task_${taskName.toLowerCase()}-.*-${exportAnnotation.format.toLowerCase()}.*.zip$`,
);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationArchiveName = fileName;
}
});
});
it('Upload annotation to job.', () => {
......
......@@ -23,12 +23,11 @@ context('Export, import an annotation task.', { browser: '!firefox' }, () => {
const directoryToArchive = imagesFolder;
const newLabelName = 'person';
let taskId;
let taskBackupArchiveShortName = `task_${taskName.toLowerCase()}_backup`;
let taskBackupArchiveFullName;
const createPointsShape = {
type: 'Shape',
labelName: labelName,
labelName,
pointsMap: [
{ x: 200, y: 200 },
{ x: 250, y: 200 },
......@@ -66,20 +65,16 @@ context('Export, import an annotation task.', { browser: '!firefox' }, () => {
.parents('.cvat-tasks-list-item')
.find('.cvat-item-open-task-actions > .cvat-menu-icon')
.trigger('mouseover');
cy.intercept('GET', '/api/v1/tasks/**?action=export').as('exportTask');
cy.get('.ant-dropdown')
.not('.ant-dropdown-hidden')
.within(() => {
cy.contains('[role="menuitem"]', new RegExp('^Export task$')).click().trigger('mouseout');
});
cy.wait('@exportTask', { timeout: 5000 }).its('response.statusCode').should('equal', 202);
cy.wait('@exportTask').its('response.statusCode').should('equal', 201);
cy.deleteTask(taskName);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.includes(taskBackupArchiveShortName)) {
taskBackupArchiveFullName = fileName;
}
cy.getDownloadFileName().then((file) => {
taskBackupArchiveFullName = file;
cy.verifyDownload(taskBackupArchiveFullName);
});
cy.deleteTask(taskName);
});
it('Import the task. Check id, labels, shape.', () => {
......
......@@ -12,7 +12,7 @@ context('Export task dataset.', () => {
const rectangleShape2Points = {
points: 'By 2 Points',
type: 'Shape',
labelName: labelName,
labelName,
firstX: 400,
firstY: 100,
secondX: 500,
......@@ -33,12 +33,7 @@ context('Export task dataset.', () => {
format: exportFormat,
};
cy.exportTask(exportDataset);
const regex = new RegExp(`^task_${taskName.toLowerCase()}-.*-${exportDataset.format.toLowerCase()}.*.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
}
});
cy.waitForDownload();
});
it('Export a task as dataset with renaming the archive.', () => {
......@@ -46,15 +41,10 @@ context('Export task dataset.', () => {
as: 'exportDatasetRenameArchive',
type: 'dataset',
format: exportFormat,
archiveCustomeName: 'task_export_dataset_custome_name'
archiveCustomeName: 'task_export_dataset_custome_name',
};
cy.exportTask(exportDataset);
const regex = new RegExp(`^${exportDataset.archiveCustomeName}.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
}
});
cy.waitForDownload();
});
});
});
......@@ -9,7 +9,7 @@ import { taskName, labelName } from '../../support/const_canvas3d';
context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format', () => {
const caseId = '91';
const cuboidCreationParams = {
labelName: labelName,
labelName,
};
const dumpTypePC = 'Sly Point Cloud Format';
let annotationPCArchiveName = '';
......@@ -37,12 +37,9 @@ context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format',
format: dumpTypePC,
};
cy.exportTask(exportAnnotation);
const regex = new RegExp(`^task_${taskName.toLowerCase()}-.*-${exportAnnotation.format.toLowerCase()}.*.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationPCArchiveName = fileName;
}
cy.getDownloadFileName().then((file) => {
annotationPCArchiveName = file;
cy.verifyDownload(annotationPCArchiveName);
});
});
......@@ -51,15 +48,12 @@ context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format',
as: 'exportAnnotationsRenameArchive',
type: 'annotations',
format: dumpTypePC,
archiveCustomeName: 'task_export_3d_annotation_custome_name_pc_format'
archiveCustomeName: 'task_export_3d_annotation_custome_name_pc_format',
};
cy.exportTask(exportAnnotationRenameArchive);
const regex = new RegExp(`^${exportAnnotationRenameArchive.archiveCustomeName}.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationPCArchiveCustomeName = fileName;
}
cy.getDownloadFileName().then((file) => {
annotationPCArchiveCustomeName = file;
cy.verifyDownload(annotationPCArchiveCustomeName);
});
cy.removeAnnotations();
cy.saveJob('PUT');
......@@ -68,14 +62,14 @@ context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format',
it('Upload "Point Cloud" format annotation to job.', () => {
cy.interactMenu('Upload annotations');
cy.readFile('cypress/fixtures/' + annotationPCArchiveName, 'binary')
cy.readFile(`cypress/fixtures/${annotationPCArchiveName}`, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
cy.contains('.cvat-menu-load-submenu-item', dumpTypePC.split(' ')[0])
.should('be.visible')
.within(() => {
cy.get('.cvat-menu-load-submenu-item-button').click().get('input[type=file]').attachFile({
fileContent: fileContent,
fileContent,
fileName: annotationPCArchiveName,
});
});
......@@ -96,7 +90,7 @@ context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format',
.find('.cvat-menu-icon')
.trigger('mouseover');
cy.contains('Upload annotations').trigger('mouseover');
cy.readFile('cypress/fixtures/' + annotationPCArchiveCustomeName, 'binary')
cy.readFile(`cypress/fixtures/${annotationPCArchiveCustomeName}`, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
cy.contains('.cvat-menu-load-submenu-item', dumpTypePC.split(' ')[0])
......@@ -104,7 +98,7 @@ context('Canvas 3D functionality. Dump/upload annotation. "Point Cloud" format',
.within(() => {
cy.get('.cvat-menu-load-submenu-item-button').click().get('input[type=file]').attachFile({
fileName: annotationPCArchiveCustomeName,
fileContent: fileContent,
fileContent,
});
});
});
......
......@@ -9,7 +9,7 @@ import { taskName, labelName } from '../../support/const_canvas3d';
context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" format.', () => {
const caseId = '92';
const cuboidCreationParams = {
labelName: labelName,
labelName,
};
const dumpTypeVC = 'Kitti Raw Format';
let annotationVCArchiveName = '';
......@@ -37,12 +37,9 @@ context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" form
format: dumpTypeVC,
};
cy.exportTask(exportAnnotation);
const regex = new RegExp(`^task_${taskName.toLowerCase()}-.*-${exportAnnotation.format.toLowerCase()}.*.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationVCArchiveName = fileName;
}
cy.getDownloadFileName().then((file) => {
annotationVCArchiveName = file;
cy.verifyDownload(annotationVCArchiveName);
});
});
......@@ -51,15 +48,12 @@ context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" form
as: 'exportAnnotationsRenameArchive',
type: 'annotations',
format: dumpTypeVC,
archiveCustomeName: 'task_export_3d_annotation_custome_name_vc_format'
archiveCustomeName: 'task_export_3d_annotation_custome_name_vc_format',
};
cy.exportTask(exportAnnotationRenameArchive);
const regex = new RegExp(`^${exportAnnotationRenameArchive.archiveCustomeName}.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.readFile(`cypress/fixtures/${fileName}`).should('exist');
annotationVCArchiveNameCustomeName = fileName;
}
cy.getDownloadFileName().then((file) => {
annotationVCArchiveNameCustomeName = file;
cy.verifyDownload(annotationVCArchiveNameCustomeName);
});
cy.removeAnnotations();
cy.saveJob('PUT');
......@@ -68,14 +62,14 @@ context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" form
it('Upload "Velodyne Points" format annotation to job.', () => {
cy.interactMenu('Upload annotations');
cy.readFile('cypress/fixtures/' + annotationVCArchiveName, 'binary')
cy.readFile(`cypress/fixtures/${annotationVCArchiveName}`, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
cy.contains('.cvat-menu-load-submenu-item', dumpTypeVC.split(' ')[0])
.should('be.visible')
.within(() => {
cy.get('.cvat-menu-load-submenu-item-button').click().get('input[type=file]').attachFile({
fileContent: fileContent,
fileContent,
fileName: annotationVCArchiveName,
});
});
......@@ -95,7 +89,7 @@ context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" form
.find('.cvat-menu-icon')
.trigger('mouseover');
cy.contains('Upload annotations').trigger('mouseover');
cy.readFile('cypress/fixtures/' + annotationVCArchiveNameCustomeName, 'binary')
cy.readFile(`cypress/fixtures/${annotationVCArchiveNameCustomeName}`, 'binary')
.then(Cypress.Blob.binaryStringToBlob)
.then((fileContent) => {
cy.contains('.cvat-menu-load-submenu-item', dumpTypeVC.split(' ')[0])
......@@ -103,10 +97,10 @@ context('Canvas 3D functionality. Dump/upload annotation. "Velodyne Points" form
.within(() => {
cy.get('.cvat-menu-load-submenu-item-button').click().get('input[type=file]').attachFile({
fileName: annotationVCArchiveNameCustomeName,
fileContent: fileContent,
fileContent,
});
});
});
});
confirmUpdate('.cvat-modal-content-load-task-annotation');
cy.contains('Annotations have been loaded').should('be.visible');
cy.get('[data-icon="close"]').click();
......
......@@ -9,7 +9,7 @@ import { taskName, labelName } from '../../support/const_canvas3d';
context('Canvas 3D functionality. Export as a dataset.', () => {
const caseId = '93';
const cuboidCreationParams = {
labelName: labelName,
labelName,
};
const dumpTypePC = 'Sly Point Cloud Format';
......@@ -31,12 +31,7 @@ context('Canvas 3D functionality. Export as a dataset.', () => {
format: dumpTypePC,
};
cy.exportTask(exportDatasetPCFormat);
const regex = new RegExp(`^task_${taskName.toLowerCase()}-.*-${exportDatasetPCFormat.format.toLowerCase()}.*.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.fixture(fileName).should('exist');
}
});
cy.waitForDownload();
});
it('Export as a dataset with "Velodyne Points" format.', () => {
......@@ -46,12 +41,7 @@ context('Canvas 3D functionality. Export as a dataset.', () => {
format: dumpTypeVC,
};
cy.exportTask(exportDatasetVCFormat);
const regex = new RegExp(`^task_${taskName.toLowerCase()}-.*-${exportDatasetVCFormat.format.toLowerCase()}.*.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.fixture(fileName).should('exist');
}
});
cy.waitForDownload();
});
it('Export as a dataset with renaming the archive.', () => {
......@@ -59,15 +49,10 @@ context('Canvas 3D functionality. Export as a dataset.', () => {
as: 'exportDatasetVCFormatRenameArchive',
type: 'dataset',
format: dumpTypeVC,
archiveCustomeName: 'task_export_3d_dataset_custome_name_vc_format'
archiveCustomeName: 'task_export_3d_dataset_custome_name_vc_format',
};
cy.exportTask(exportDatasetVCFormatRenameArchive);
const regex = new RegExp(`^${exportDatasetVCFormatRenameArchive.archiveCustomeName}.zip$`);
cy.task('listFiles', 'cypress/fixtures').each((fileName) => {
if (fileName.match(regex)) {
cy.fixture(fileName).should('exist');
}
});
cy.waitForDownload();
cy.removeAnnotations();
cy.saveJob('PUT');
});
......
......@@ -11,7 +11,7 @@ context('Dump annotation if cuboid created.', () => {
const createCuboidShape2Points = {
points: 'From rectangle',
type: 'Shape',
labelName: labelName,
labelName,
firstX: 250,
firstY: 350,
secondX: 350,
......@@ -36,6 +36,7 @@ context('Dump annotation if cuboid created.', () => {
format: exportFormat,
};
cy.exportTask(exportAnnotation);
cy.waitForDownload();
});
it('Error notification is not exists.', () => {
......
......@@ -4,16 +4,21 @@
/// <reference types="cypress" />
const { imageGenerator } = require('../plugins/imageGenerator/addPlugin');
const { createZipArchive } = require('../plugins/createZipArchive/addPlugin');
const { compareImages } = require('../plugins/compareImages/addPlugin');
const fs = require('fs');
// eslint-disable-next-line import/no-extraneous-dependencies
const { isFileExist } = require('cy-verify-downloads');
const { imageGenerator } = require('./imageGenerator/addPlugin');
const { createZipArchive } = require('./createZipArchive/addPlugin');
const { compareImages } = require('./compareImages/addPlugin');
const { unpackZipArchive } = require('./unpackZipArchive/addPlugin');
module.exports = (on, config) => {
// eslint-disable-next-line import/no-extraneous-dependencies
require('@cypress/code-coverage/task')(on, config);
on('task', { imageGenerator });
on('task', { createZipArchive });
on('task', { compareImages });
on('task', { unpackZipArchive });
on('task', {
log(message) {
console.log(message);
......@@ -25,6 +30,7 @@ module.exports = (on, config) => {
return fs.readdirSync(folderName);
},
});
on('task', { isFileExist });
// Try to resolve "Cypress failed to make a connection to the Chrome DevTools Protocol"
// https://github.com/cypress-io/cypress/issues/7450
on('before:browser:launch', (browser, launchOptions) => {
......
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT
const path = require('path');
const extract = require('extract-zip');
async function unpackZipArchive(args) {
const { arhivePath } = args;
const absolutePath = path.dirname(path.resolve(arhivePath));
await extract(arhivePath, { dir: absolutePath });
return null;
}
exports.unpackZipArchive = unpackZipArchive;
// Copyright (C) 2021 Intel Corporation
//
// SPDX-License-Identifier: MIT
Cypress.Commands.add('unpackZipArchive', (arhivePath) => cy.task('unpackZipArchive', {
arhivePath,
}));
......@@ -9,6 +9,8 @@ require('../plugins/imageGenerator/imageGeneratorCommand');
require('../plugins/createZipArchive/createZipArchiveCommand');
require('cypress-localstorage-commands');
require('../plugins/compareImages/compareImagesCommand');
require('../plugins/unpackZipArchive/unpackZipArchiveCommand');
require('cy-verify-downloads').addCustomCommand();
let selectedValueGlobal = '';
......@@ -226,7 +228,6 @@ Cypress.Commands.add('openJob', (jobID = 0, removeAnnotations = true, expectedFa
} else {
cy.get('.cvat-canvas-container').should('exist');
}
if (removeAnnotations) {
cy.document().then((doc) => {
const objects = Array.from(doc.querySelectorAll('.cvat_canvas_shape'));
......@@ -723,10 +724,9 @@ Cypress.Commands.add('closeModalUnsupportedPlatform', () => {
});
Cypress.Commands.add('exportTask', ({
as, type, format, archiveCustomeName,
type, format, archiveCustomeName,
}) => {
cy.interactMenu('Export task dataset');
cy.intercept('GET', `/api/v1/tasks/**/${type}**`).as(as);
cy.get('.cvat-modal-export-task').should('be.visible').find('.cvat-modal-export-select').click();
cy.contains('.cvat-modal-export-option-item', format).should('be.visible').click();
cy.get('.cvat-modal-export-task').find('.cvat-modal-export-select').should('contain.text', format);
......@@ -739,7 +739,4 @@ Cypress.Commands.add('exportTask', ({
cy.contains('button', 'OK').click();
cy.get('.cvat-notification-notice-export-task-start').should('be.visible');
cy.closeNotification('.cvat-notification-notice-export-task-start');
cy.wait(`@${as}`, { timeout: 5000 }).its('response.statusCode').should('equal', 202);
cy.wait(`@${as}`).its('response.statusCode').should('equal', 201);
cy.wait(2000); // Waiting for a full file download
});
......@@ -28,9 +28,9 @@ Cypress.Commands.add(
cy.get('.cvat-create-project-content').within(() => {
cy.contains('Submit').click();
});
if (expectedResult == 'success') {
if (expectedResult === 'success') {
cy.get('.cvat-notification-create-project-success').should('exist').find('[data-icon="close"]').click();
} else if (expectedResult == 'fail') {
} else if (expectedResult === 'fail') {
cy.get('.cvat-notification-create-project-success').should('not.exist');
}
cy.goToProjectsList();
......@@ -67,9 +67,10 @@ Cypress.Commands.add('deleteProject', (projectName, projectID, expectedResult =
}
});
Cypress.Commands.add('exportProject', ({ projectName, as, type, dumpType, archiveCustomeName }) => {
Cypress.Commands.add('exportProject', ({
projectName, type, dumpType, archiveCustomeName,
}) => {
cy.projectActions(projectName);
cy.intercept('GET', `/api/v1/projects/**/${type}**`).as(as);
cy.get('.cvat-project-actions-menu').contains('Export project dataset').click();
cy.get('.cvat-modal-export-project').should('be.visible').find('.cvat-modal-export-select').click();
cy.contains('.cvat-modal-export-option-item', dumpType).should('be.visible').click();
......@@ -82,8 +83,20 @@ Cypress.Commands.add('exportProject', ({ projectName, as, type, dumpType, archiv
}
cy.get('.cvat-modal-export-project').contains('button', 'OK').click();
cy.get('.cvat-notification-notice-export-project-start').should('be.visible');
cy.wait(`@${as}`, { timeout: 5000 }).its('response.statusCode').should('equal', 202);
cy.wait(`@${as}`).its('response.statusCode').should('equal', 201);
});
Cypress.Commands.add('getDownloadFileName', () => {
cy.intercept('GET', '**=download').as('download');
cy.wait('@download').then((download) => {
const filename = download.response.headers['content-disposition'].split('filename="b\'')[1].split('\'')[0];
return filename;
});
});
Cypress.Commands.add('waitForDownload', () => {
cy.getDownloadFileName().then((filename) => {
cy.verifyDownload(filename);
});
});
Cypress.Commands.add('deleteProjectViaActions', (projectName) => {
......
......@@ -7,10 +7,12 @@
"dependencies": {
"@cypress/code-coverage": "^3.9.10",
"archiver": "^5.3.0",
"cy-verify-downloads": "^0.0.5",
"cypress": "^8.3.1",
"cypress-file-upload": "^5.0.8",
"cypress-localstorage-commands": "^1.5.0",
"cypress-plugin-tab": "^1.0.5",
"extract-zip": "^2.0.1",
"jimp": "^0.16.1"
}
},
......@@ -3329,6 +3331,11 @@
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
"integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s="
},
"node_modules/cy-verify-downloads": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/cy-verify-downloads/-/cy-verify-downloads-0.0.5.tgz",
"integrity": "sha512-aRK7VvKG5rmDJK4hjZ27KM2oOOz0cMO7z/j4zX8qCc4ffXZS1XRJkofUY0w5u6MCB/wUsNMs03VuvkeR2tNPoQ=="
},
"node_modules/cypress": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-8.3.1.tgz",
......@@ -10843,6 +10850,11 @@
"resolved": "https://registry.npmjs.org/css.escape/-/css.escape-1.5.1.tgz",
"integrity": "sha1-QuJ9T6BK4y+TGktNQZH6nN3ul8s="
},
"cy-verify-downloads": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/cy-verify-downloads/-/cy-verify-downloads-0.0.5.tgz",
"integrity": "sha512-aRK7VvKG5rmDJK4hjZ27KM2oOOz0cMO7z/j4zX8qCc4ffXZS1XRJkofUY0w5u6MCB/wUsNMs03VuvkeR2tNPoQ=="
},
"cypress": {
"version": "8.3.1",
"resolved": "https://registry.npmjs.org/cypress/-/cypress-8.3.1.tgz",
......
......@@ -5,12 +5,14 @@
"cypress:run:chrome:canvas3d": "cypress run --headed --browser chrome --env coverage=false --config-file cypress_canvas3d.json"
},
"dependencies": {
"archiver": "^5.3.0",
"jimp": "^0.16.1",
"@cypress/code-coverage": "^3.9.10",
"archiver": "^5.3.0",
"cy-verify-downloads": "^0.0.5",
"cypress": "^8.3.1",
"cypress-file-upload": "^5.0.8",
"cypress-localstorage-commands": "^1.5.0",
"cypress-plugin-tab": "^1.0.5"
"cypress-plugin-tab": "^1.0.5",
"extract-zip": "^2.0.1",
"jimp": "^0.16.1"
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册