Skip to content

Commit d3de9c5

Browse files
Remove explicit tree-select API waits in tests
1 parent 89a35cb commit d3de9c5

File tree

2 files changed

+21
-44
lines changed

2 files changed

+21
-44
lines changed

cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,10 @@ describe('Automate Collect logs Edit form operations', () => {
226226
describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit', () => {
227227
beforeEach(() => {
228228
// Select "Zone:" accordion item
229-
cy.interceptApi({
230-
alias: 'treeSelectApi',
231-
urlPattern:
232-
/ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/,
233-
triggerFn: () =>
234-
cy.selectAccordionItem([
235-
MANAGEIQ_REGION_ACCORDION_ITEM,
236-
ZONE_ACCORDION_ITEM,
237-
]),
238-
});
229+
cy.selectAccordionItem([
230+
MANAGEIQ_REGION_ACCORDION_ITEM,
231+
ZONE_ACCORDION_ITEM,
232+
]);
239233
// Select collect logs tab and open edit form
240234
goToCollectLogsTabAndOpenEditForm();
241235
});

cypress/e2e/ui/validate-intercept-api-command.cy.js

Lines changed: 17 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@ describe('Validate intercept command', () => {
1010

1111
it('Should register the alias, intercept, wait & validate response status code when an API is fired', () => {
1212
cy.accordion('Diagnostics');
13-
cy.interceptApi({
14-
alias: 'treeSelectApi',
15-
urlPattern: /\/ops\/tree_select\?id=.*&text=.*/,
16-
triggerFn: () => cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]),
17-
onApiResponse: (interception) => {
18-
expect(interception.response.statusCode).to.equal(200);
19-
},
20-
}).then(() => {
21-
// verifies that the alias is set and the request is intercepted & awaited
22-
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
23-
expect(interceptedAliasesObject).to.have.property('post-treeSelectApi');
24-
});
13+
// Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi'
14+
cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]);
15+
// verifies that the alias is set and the request is intercepted & awaited
16+
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
17+
expect(interceptedAliasesObject).to.have.property('post-treeSelectApi');
2518
});
2619
});
2720

@@ -32,19 +25,14 @@ describe('Validate intercept command', () => {
3225
urlPattern: /\/ops\/accordion_select\?id=.*/,
3326
triggerFn: () => cy.accordion('Diagnostics'),
3427
});
35-
// second api with alias 'treeSelectApi'
36-
cy.interceptApi({
37-
alias: 'treeSelectApi',
38-
urlPattern: /\/ops\/tree_select\?id=.*&text=.*/,
39-
triggerFn: () => cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]),
40-
}).then(() => {
41-
// verifies that both the aliases are set and the request is intercepted & awaited
42-
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
43-
expect(interceptedAliasesObject).to.include.all.keys(
44-
'post-accordionSelectApi',
45-
'post-treeSelectApi'
46-
);
47-
});
28+
// second api with alias 'treeSelectApi'(Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi')
29+
cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]);
30+
// verifies that both the aliases are set and the request is intercepted & awaited
31+
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
32+
expect(interceptedAliasesObject).to.include.all.keys(
33+
'post-accordionSelectApi',
34+
'post-treeSelectApi'
35+
);
4836
});
4937
});
5038

@@ -59,15 +47,10 @@ describe('Validate intercept command', () => {
5947
expect(Object.keys(interceptedAliasesObject).length).to.equal(1);
6048
});
6149
});
62-
// second first api with alias 'treeSelectApi'
63-
cy.interceptApi({
64-
alias: 'treeSelectApi',
65-
urlPattern: /\/ops\/tree_select\?id=.*&text=.*/,
66-
triggerFn: () => cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]),
67-
}).then(() => {
68-
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
69-
expect(Object.keys(interceptedAliasesObject).length).to.equal(2);
70-
});
50+
// second api with alias 'treeSelectApi'(Tree select api wait is handled from selectAccordionItem with alias 'treeSelectApi')
51+
cy.selectAccordionItem([/^ManageIQ Region:/, /^Zone:/]);
52+
cy.getInterceptedApiAliases().then((interceptedAliasesObject) => {
53+
expect(Object.keys(interceptedAliasesObject).length).to.equal(2);
7154
});
7255
// third api with a duplicate alias as above 'accordionSelectApi'
7356
cy.interceptApi({

0 commit comments

Comments
 (0)