Skip to content

Commit 48d94b5

Browse files
Fix Jobs tests 6/25 (#2582)
1 parent 7fb276d commit 48d94b5

File tree

1 file changed

+142
-66
lines changed

1 file changed

+142
-66
lines changed

cypress/e2e/awx/views/jobs.cy.ts

Lines changed: 142 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,30 @@ describe('Jobs: List', () => {
1313
let inventory: Inventory;
1414
let jobTemplate: JobTemplate;
1515
let job: Job;
16+
let project: Project;
17+
let organization: Organization;
18+
19+
before(() => {
20+
cy.createAwxOrganization().then((org) => {
21+
organization = org;
22+
cy.createAwxProject({ organization: org.id }).then((p) => {
23+
project = p;
24+
});
25+
});
26+
});
27+
28+
after(() => {
29+
cy.deleteAwxProject(project, { failOnStatusCode: false }).then(() => {
30+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
31+
});
32+
});
1633

1734
beforeEach(function () {
18-
const globalAwxOrganization = this.globalAwxOrganization as Organization;
19-
const globalProject = this.globalProject as Project;
20-
cy.createAwxInventory({ organization: globalAwxOrganization.id }).then((inv) => {
35+
cy.createAwxInventory({ organization: organization.id }).then((inv) => {
2136
inventory = inv;
2237
cy.createAwxJobTemplate({
23-
organization: globalAwxOrganization.id,
24-
project: globalProject.id,
38+
organization: organization.id,
39+
project: project.id,
2540
inventory: inv.id,
2641
}).then((jt) => {
2742
jobTemplate = jt;
@@ -52,6 +67,7 @@ describe('Jobs: List', () => {
5267
cy.contains(jobName);
5368
cy.clearAllFilters();
5469
});
70+
5571
it('can relaunch the job and navigate to job output', () => {
5672
cy.navigateTo('awx', 'jobs');
5773
const jobId = job.id ? job.id.toString() : '';
@@ -108,28 +124,38 @@ describe('Jobs: List', () => {
108124
describe('Jobs: Delete', () => {
109125
let inventory: Inventory;
110126
let jobTemplate: JobTemplate;
127+
let project: Project;
111128
let organization: Organization;
112129

113-
beforeEach(function () {
114-
const globalProject = this.globalProject as Project;
115-
116-
cy.createAwxOrganization('E2E Organization' + randomString(4)).then((org) => {
130+
before(() => {
131+
cy.createAwxOrganization().then((org) => {
117132
organization = org;
118-
cy.createAwxInventory({ organization: organization.id }).then((inv) => {
119-
inventory = inv;
120-
cy.createAwxJobTemplate({
121-
organization: organization.id,
122-
project: globalProject.id,
123-
inventory: inv.id,
124-
}).then((jt) => {
125-
jobTemplate = jt;
126-
});
133+
cy.createAwxProject({ organization: org.id }).then((p) => {
134+
project = p;
135+
});
136+
});
137+
});
138+
139+
after(() => {
140+
cy.deleteAwxProject(project, { failOnStatusCode: false }).then(() => {
141+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
142+
});
143+
});
144+
145+
beforeEach(function () {
146+
cy.createAwxInventory({ organization: organization.id }).then((inv) => {
147+
inventory = inv;
148+
cy.createAwxJobTemplate({
149+
organization: organization.id,
150+
project: project.id,
151+
inventory: inv.id,
152+
}).then((jt) => {
153+
jobTemplate = jt;
127154
});
128155
});
129156
});
130157

131158
afterEach(() => {
132-
cy.deleteAwxOrganization(organization);
133159
cy.deleteAwxJobTemplate(jobTemplate, { failOnStatusCode: false });
134160
cy.deleteAwxInventory(inventory, { failOnStatusCode: false });
135161
});
@@ -162,6 +188,7 @@ describe('Jobs: Delete', () => {
162188
}
163189
);
164190
});
191+
165192
it('can delete a job from the jobs list toolbar', () => {
166193
const jobTemplateId = jobTemplate.id ? jobTemplate.id.toString() : '';
167194
cy.requestPost<UnifiedJobList>(awxAPI`/job_templates/${jobTemplateId}/launch/`, {}).then(
@@ -195,6 +222,17 @@ describe('Jobs: Delete', () => {
195222

196223
describe('Jobs: Output and Details Screen', () => {
197224
let thisId: string;
225+
let organization: Organization;
226+
227+
before(() => {
228+
cy.createAwxOrganization().then((org) => {
229+
organization = org;
230+
});
231+
});
232+
233+
after(() => {
234+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
235+
});
198236

199237
it('can launch a Management job, let it finish, and assert expected results on the output screen', () => {
200238
cy.navigateTo('awx', 'management-jobs');
@@ -223,13 +261,14 @@ describe('Jobs: Output and Details Screen', () => {
223261
cy.getByDataCy('status').should('contain', 'Success');
224262
cy.getByDataCy('type').should('contain', 'Management job');
225263
});
264+
226265
it('can launch a Source Control Update job, let it finish, and assert expected results on the output screen', function () {
227266
const projectName = 'E2E Project Jobs ' + randomString(4);
228267
cy.navigateTo('awx', 'projects');
229268
cy.verifyPageTitle('Projects');
230269
cy.clickLink(/^Create project$/);
231270
cy.get('[data-cy="name"]').type(projectName);
232-
cy.singleSelectByDataCy('organization', `${(this.globalAwxOrganization as Organization).name}`);
271+
cy.singleSelectByDataCy('organization', `${organization.name}`);
233272
cy.selectDropdownOptionByResourceName('source_control_type', 'Git');
234273
cy.get('[data-cy="scm-url"]').type('https://github.com/ansible/ansible-ui');
235274
cy.intercept('POST', awxAPI`/projects/`).as('newProject');
@@ -267,28 +306,40 @@ describe('Job template: Output and Details Screen', () => {
267306
let inventory: Inventory;
268307
let jobTemplate: JobTemplate;
269308
let thisId: string;
309+
let project: Project;
270310
let organization: Organization;
271311

312+
before(() => {
313+
cy.createAwxOrganization().then((org) => {
314+
organization = org;
315+
cy.createAwxProject({ organization: org.id }).then((p) => {
316+
project = p;
317+
});
318+
});
319+
});
320+
321+
after(() => {
322+
cy.deleteAwxProject(project, { failOnStatusCode: false }).then(() => {
323+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
324+
});
325+
});
326+
272327
beforeEach(function () {
273-
cy.createAwxOrganization().then((o) => {
274-
organization = o;
275-
cy.createAwxInventory({ organization: organization.id }).then((i) => {
276-
inventory = i;
277-
cy.createAwxJobTemplate({
278-
organization: organization.id,
279-
project: (this.globalProject as Project).id,
280-
inventory: i.id,
281-
}).then((jt) => {
282-
jobTemplate = jt;
283-
});
328+
cy.createAwxInventory({ organization: organization.id }).then((i) => {
329+
inventory = i;
330+
cy.createAwxJobTemplate({
331+
organization: organization.id,
332+
project: project.id,
333+
inventory: i.id,
334+
}).then((jt) => {
335+
jobTemplate = jt;
284336
});
285337
});
286338
});
287339

288340
afterEach(() => {
289341
cy.deleteAwxJobTemplate(jobTemplate, { failOnStatusCode: false });
290342
cy.deleteAwxInventory(inventory, { failOnStatusCode: false });
291-
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
292343
});
293344

294345
it('can launch a Playbook Run job, let it finish, and assert expected results on the output screen', () => {
@@ -325,25 +376,38 @@ describe('Job template: Output and Details Screen', () => {
325376
describe('Inventory source: Output and Details Screen', () => {
326377
let inventory: Inventory;
327378
let inventorySource: InventorySource;
328-
let organization: Organization;
329379
let thisId: string;
330380

381+
let project: Project;
382+
let organization: Organization;
383+
384+
before(() => {
385+
cy.createAwxOrganization().then((org) => {
386+
organization = org;
387+
cy.createAwxProject({ organization: org.id }).then((p) => {
388+
project = p;
389+
});
390+
});
391+
});
392+
393+
after(() => {
394+
cy.deleteAwxProject(project, { failOnStatusCode: false }).then(() => {
395+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
396+
});
397+
});
398+
331399
beforeEach(function () {
332-
cy.createAwxOrganization().then((o) => {
333-
organization = o;
334-
cy.createAwxInventory({ organization: organization.id }).then((i) => {
335-
inventory = i;
336-
cy.createAwxInventorySource(i, this.globalProject as Project).then((invSrc) => {
337-
inventorySource = invSrc;
338-
});
400+
cy.createAwxInventory({ organization: organization.id }).then((i) => {
401+
inventory = i;
402+
cy.createAwxInventorySource(i, project).then((invSrc) => {
403+
inventorySource = invSrc;
339404
});
340405
});
341406
});
342407

343408
afterEach(() => {
344409
cy.deleteAwxInventorySource(inventorySource, { failOnStatusCode: false });
345410
cy.deleteAwxInventory(inventory, { failOnStatusCode: false });
346-
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
347411
});
348412

349413
it('can launch an Inventory Sync job, let it finish, and assert expected results on the output screen', () => {
@@ -379,35 +443,48 @@ describe('Inventory source: Output and Details Screen', () => {
379443
describe('Workflow template: Output and Details Screen', () => {
380444
let workflowJobTemplate: WorkflowJobTemplate;
381445
let jobTemplate: JobTemplate;
382-
let organization: Organization;
383446
let inventory: Inventory;
447+
let project: Project;
448+
let organization: Organization;
449+
450+
before(() => {
451+
cy.createAwxOrganization().then((org) => {
452+
organization = org;
453+
cy.createAwxProject({ organization: org.id }).then((p) => {
454+
project = p;
455+
});
456+
});
457+
});
458+
459+
after(() => {
460+
cy.deleteAwxProject(project, { failOnStatusCode: false }).then(() => {
461+
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
462+
});
463+
});
384464

385465
beforeEach(function () {
386-
cy.createAwxOrganization().then((orgB) => {
387-
organization = orgB;
388-
cy.createAwxInventory({ organization: organization.id }).then((i) => {
389-
inventory = i;
390-
cy.createAwxJobTemplate({
466+
cy.createAwxInventory({ organization: organization.id }).then((i) => {
467+
inventory = i;
468+
cy.createAwxJobTemplate({
469+
organization: organization.id,
470+
project: project.id,
471+
inventory: inventory.id,
472+
}).then((jt) => {
473+
jobTemplate = jt;
474+
cy.createAwxWorkflowJobTemplate({
391475
organization: organization.id,
392-
project: (this.globalProject as Project).id,
393476
inventory: inventory.id,
394-
}).then((jt) => {
395-
jobTemplate = jt;
396-
cy.createAwxWorkflowJobTemplate({
397-
organization: organization.id,
398-
inventory: inventory.id,
399-
}).then((wfjt) => {
400-
workflowJobTemplate = wfjt;
401-
cy.createAwxWorkflowVisualizerJobTemplateNode(workflowJobTemplate, jobTemplate).then(
402-
(jobTemplateNode) => {
403-
cy.createAwxWorkflowVisualizerManagementNode(workflowJobTemplate, 2).then(
404-
(managementNode) => {
405-
cy.createWorkflowJTFailureNodeLink(jobTemplateNode, managementNode);
406-
}
407-
);
408-
}
409-
);
410-
});
477+
}).then((wfjt) => {
478+
workflowJobTemplate = wfjt;
479+
cy.createAwxWorkflowVisualizerJobTemplateNode(workflowJobTemplate, jobTemplate).then(
480+
(jobTemplateNode) => {
481+
cy.createAwxWorkflowVisualizerManagementNode(workflowJobTemplate, 2).then(
482+
(managementNode) => {
483+
cy.createWorkflowJTFailureNodeLink(jobTemplateNode, managementNode);
484+
}
485+
);
486+
}
487+
);
411488
});
412489
});
413490
});
@@ -417,7 +494,6 @@ describe('Workflow template: Output and Details Screen', () => {
417494
cy.deleteAwxWorkflowJobTemplate(workflowJobTemplate, { failOnStatusCode: false });
418495
cy.deleteAwxJobTemplate(jobTemplate, { failOnStatusCode: false });
419496
cy.deleteAwxInventory(inventory, { failOnStatusCode: false });
420-
cy.deleteAwxOrganization(organization, { failOnStatusCode: false });
421497
});
422498

423499
it('can launch a Workflow job, let it finish, and assert expected results on the output screen', () => {

0 commit comments

Comments
 (0)