Skip to content

Commit da4cb68

Browse files
archibald1418Oleg Valiulin
andauthored
Add cy.cmds to open tasks and projects by ids with checks (#9777)
Co-authored-by: Oleg Valiulin <oleg.valiulin@cvat.ai>
1 parent df12bf5 commit da4cb68

File tree

7 files changed

+22
-24
lines changed

7 files changed

+22
-24
lines changed

tests/cypress/e2e/actions_projects_models/markdown_base_pipeline.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,7 @@ context('Basic markdown pipeline', () => {
7070
}).then((taskResponse) => {
7171
taskID = taskResponse.taskID;
7272
[jobID] = taskResponse.jobIDs;
73-
74-
cy.visit(`/tasks/${taskID}`);
75-
cy.get('.cvat-task-details').should('exist').and('be.visible');
73+
cy.openTaskById(taskID);
7674
cy.assignTaskToUser(additionalUsers.taskAssignee.username);
7775
cy.assignJobToUser(jobID, additionalUsers.jobAssignee.username);
7876
});
@@ -92,11 +90,6 @@ context('Basic markdown pipeline', () => {
9290
});
9391

9492
describe('Markdown text can be bounded to the project', () => {
95-
function openProject() {
96-
cy.visit(`/projects/${projectID}`);
97-
cy.get('.cvat-project-details').should('exist').and('be.visible');
98-
}
99-
10093
function openGuide() {
10194
cy.get('.cvat-md-guide-control-wrapper button').click();
10295
cy.url().should('to.match', /\/projects\/\d+\/guide/);
@@ -124,7 +117,7 @@ context('Basic markdown pipeline', () => {
124117
}
125118

126119
function setupGuide(value) {
127-
openProject();
120+
cy.openProjectById(projectID);
128121
openGuide();
129122
updatePlainText(value);
130123
}

tests/cypress/e2e/actions_tasks/task_changes_status_after_initial_save.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,7 @@ context('Task status updated after initial save.', () => {
5353

5454
describe(`Testing "${labelName}"`, () => {
5555
it('State of the created task should be "new".', () => {
56-
cy.intercept('GET', `/tasks/${taskID}`).as('visitTaskPage');
57-
cy.visit(`/tasks/${taskID}`);
58-
cy.wait('@visitTaskPage');
56+
cy.openTaskById(taskID);
5957
cy.get('.cvat-job-item .cvat-job-item-state .ant-select-selection-item').invoke('text').should('equal', 'new');
6058
});
6159

tests/cypress/e2e/actions_tasks2/test_default_attribute.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,7 @@ context('Test default value for an attribute', () => {
7979
describe('Test can change default attribute', () => {
8080
it('Can change default attribute value on task page', () => {
8181
const newDefaultValue = 'third';
82-
cy.visit(`/tasks/${taskID}`);
83-
cy.get('.cvat-task-details').should('exist').and('be.visible');
82+
cy.openTaskById(taskID);
8483
cy.get('.cvat-constructor-viewer-item').within(() => {
8584
cy.get('[aria-label="edit"]').click();
8685
});

tests/cypress/e2e/features/bulk_actions.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ context('Bulk actions in UI', () => {
100100

101101
describe('Bulk-change object attributes, confirm UI state', () => {
102102
before(() => {
103-
cy.visit(`/projects/${projectTwoTasks}`);
103+
cy.openProjectById(projectTwoTasks);
104104
});
105105
context('Project page, change tasks', () => {
106106
it('"Select all", all items are selected, "Deselect" button is visible', () => {
@@ -131,10 +131,7 @@ context('Bulk actions in UI', () => {
131131
});
132132
cy.get('.cvat-bulk-progress-wrapper').should('be.visible');
133133

134-
// Navigate to task with 2 jobs
135-
cy.visit(`tasks/${taskTwoJobs.ID}`);
136-
cy.get('.cvat-spinner').should('not.exist');
137-
cy.get('.cvat-task-details').should('exist');
134+
cy.openTaskById(taskTwoJobs.ID);
138135

139136
// Ensure task was assigned to admin
140137
cy.get('.cvat-user-search-field').first()
@@ -146,7 +143,7 @@ context('Bulk actions in UI', () => {
146143

147144
context('Task page, change jobs', () => {
148145
before(() => {
149-
cy.visit(`tasks/${taskTwoJobs.ID}`);
146+
cy.openTaskById(taskTwoJobs.ID);
150147
});
151148

152149
it('Bulk-change assignees', () => {
@@ -179,7 +176,7 @@ context('Bulk actions in UI', () => {
179176

180177
describe('Bulk export', () => {
181178
before(() => {
182-
cy.visit(`tasks/${taskTwoJobs.ID}`);
179+
cy.openTaskById(taskTwoJobs.ID);
183180
});
184181
it('Bulk-export job annotations', () => {
185182
getBulkActionsMenu().within(() => {
@@ -208,7 +205,7 @@ context('Bulk actions in UI', () => {
208205

209206
describe('Delete all tasks in project', () => {
210207
before(() => {
211-
cy.visit(`/projects/${projectTwoTasks}`);
208+
cy.openProjectById(projectTwoTasks);
212209
});
213210

214211
it('Delete all tasks, ensure deletion', () => {

tests/cypress/e2e/features/ground_truth_jobs.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,8 +126,7 @@ context('Ground truth jobs', () => {
126126
[jobID] = taskResponse.jobIDs;
127127
}
128128
}).then(() => {
129-
cy.visit(`/tasks/${taskID}`);
130-
cy.get('.cvat-task-details').should('exist').and('be.visible');
129+
cy.openTaskById(taskID);
131130
});
132131
}
133132

tests/cypress/support/commands.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,12 @@ Cypress.Commands.add('openTask', (taskName, projectSubsetFieldValue) => {
493493
}
494494
});
495495

496+
Cypress.Commands.add('openTaskById', (taskId) => {
497+
cy.visit(`/tasks/${taskId}`);
498+
cy.get('.cvat-spinner').should('not.exist');
499+
cy.get('.cvat-task-details').should('exist').and('be.visible');
500+
});
501+
496502
Cypress.Commands.add('saveJob', (method = 'PATCH', status = 200, as = 'saveJob') => {
497503
cy.intercept(method, '/api/jobs/**').as(as);
498504
cy.clickSaveAnnotationView();

tests/cypress/support/commands_projects.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ Cypress.Commands.add('openProject', (projectName) => {
7878
cy.get('.cvat-project-details').should('exist');
7979
});
8080

81+
Cypress.Commands.add('openProjectById', (projectId) => {
82+
cy.visit(`/projects/${projectId}`);
83+
cy.get('.cvat-spinner').should('not.exist');
84+
cy.get('.cvat-project-details').should('exist').and('be.visible');
85+
});
86+
8187
Cypress.Commands.add('openProjectActions', (projectName) => {
8288
cy.contains('.cvat-projects-project-item-title', projectName)
8389
.parents('.cvat-projects-project-item-card')

0 commit comments

Comments
 (0)