-
Notifications
You must be signed in to change notification settings - Fork 2.9k
/
case_103_project_export.js
192 lines (180 loc) · 6.59 KB
/
case_103_project_export.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
// Copyright (C) 2021-2022 Intel Corporation
// Copyright (C) 2022 CVAT.ai Corporation
//
// SPDX-License-Identifier: MIT
/// <reference types="cypress" />
import { projectName, labelName } from '../../support/const_project';
context('Export project dataset.', { browser: '!firefox' }, () => {
const caseID = 103;
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_${task.name.replace(' ', '_').toLowerCase()}`;
const width = 800;
const height = 800;
const posX = 10;
const posY = 10;
const color = 'gray';
const archiveName = `${imageFileName}.zip`;
const archivePath = `cypress/fixtures/${archiveName}`;
const imagesFolder = `cypress/fixtures/${imageFileName}`;
const directoryToArchive = imagesFolder;
let datasetArchiveName;
function checkCounTasksInXML(projectParams, expectedCount) {
cy.exportProject(projectParams);
cy.downloadExport().then((file) => {
cy.verifyDownload(file);
});
cy.unpackZipArchive(`cypress/fixtures/${projectParams.archiveCustomName}.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);
});
cy.goBack();
}
before(() => {
cy.imageGenerator(imagesFolder, imageFileName, width, height, color, posX, posY, labelName, imagesCount);
cy.createZipArchive(directoryToArchive, archivePath);
cy.openProject(projectName);
cy.createAnnotationTask(
task.nameSecond,
task.labelSecond,
task.attrNameSecond,
task.attrValueSecond,
archiveName,
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,
);
});
after(() => {
cy.logout();
cy.getAuthKey().then((authKey) => {
cy.deleteProjects(authKey, [projectName]);
});
});
describe(`Testing "Case ${caseID}"`, () => {
it('Export project dataset. Annotation.', () => {
cy.goToProjectsList();
const exportAnnotation = {
projectName,
as: 'exportAnnotations',
type: 'annotations',
dumpType: 'CVAT for images',
};
cy.exportProject(exportAnnotation);
cy.downloadExport().then((file) => {
cy.verifyDownload(file);
});
cy.goBack();
});
it('Export project dataset. Dataset.', () => {
cy.goToProjectsList();
const exportDataset = {
projectName,
as: 'exportDataset',
type: 'dataset',
dumpType: 'CVAT for images',
};
cy.exportProject(exportDataset);
cy.downloadExport().then((file) => {
cy.verifyDownload(file);
datasetArchiveName = file;
});
cy.goBack();
});
it('Export project dataset. Annotation. Rename an archive.', () => {
cy.goToProjectsList();
const exportAnnotationsRenameArchive = {
projectName,
as: 'exportAnnotationsRenameArchive',
type: 'annotations',
dumpType: 'CVAT for images',
archiveCustomName: 'export_project_annotation',
};
// Check issue 3810
checkCounTasksInXML(exportAnnotationsRenameArchive, 2);
cy.openProject(projectName);
cy.deleteTask(task.nameSecond);
cy.goToProjectsList();
checkCounTasksInXML(exportAnnotationsRenameArchive, 1);
});
it('Import dataset.', () => {
cy.openProject(projectName);
cy.deleteTask(task.name);
cy.get('.cvat-tasks-list-item')
.should('have.length', 1)
.should('have.attr', 'style')
.and('contain', 'pointer-events: none; opacity: 0.5;');
cy.goToProjectsList();
const importDataset = {
projectName,
format: 'CVAT 1.1',
archive: datasetArchiveName,
};
cy.importProject(importDataset);
cy.verifyNotification();
cy.openProject(projectName);
cy.get('.cvat-tasks-list-item').should('have.length', 1);
});
it('Import dataset to project without labels.', () => {
// Deleting the task
cy.get('.cvat-item-task-name').then((name) => {
cy.deleteTask(name.text());
});
cy.get('.cvat-tasks-list-item')
.should('have.length', 1)
.should('have.attr', 'style')
.and('contain', 'pointer-events: none; opacity: 0.5;');
// Deleting the label
cy.get('.cvat-constructor-viewer-item')
.should('have.length', 1)
.find('[aria-label="delete"]')
.click();
cy.get('.cvat-modal-delete-label')
.contains('button', 'OK')
.click();
cy.get('.cvat-modal-delete-label').should('not.exist');
cy.goToProjectsList();
const importDataset = {
projectName,
format: 'CVAT 1.1',
archive: datasetArchiveName,
};
cy.importProject(importDataset);
cy.verifyNotification();
cy.openProject(projectName);
cy.get('.cvat-tasks-list-item').should('have.length', 1);
cy.get('.cvat-constructor-viewer-item')
.should('have.length', 1)
.should('have.text', labelName);
});
});
});