From 80d7cbdcb93b4cca64ad6ded64b7868f591f2cf6 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 17:25:44 +0530 Subject: [PATCH 1/4] Removed notification alert suppression logic --- .../edit_collect_logs.cy.js | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js index 8e6a775958a..d71cd00c64b 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js @@ -1,17 +1,5 @@ /* eslint-disable no-undef */ -function disableNotificationsIfVisible() { - // Look for notification popups and disable them if present - cy.get('body').then(($body) => { - const $link = $body.find( - '.miq-toast-wrapper .row .alert a:contains("Disable notifications")' - ); - if ($link.length && $link.is(':visible')) { - cy.wrap($link).click({ force: true }); - } - }); -} - function resetProtocolForServer() { // Select Diagnostics cy.get('.panel #control_diagnostics_accord .panel-title a') @@ -161,12 +149,7 @@ function saveButtonValidation() { describe('Automate Collect logs Edit form operations', () => { beforeEach(() => { - cy.intercept('GET', '/api/notifications').as('getNotifications'); cy.login(); - // After logging in, ensure the notification banner is disabled to avoid blocking other elements - cy.wait('@getNotifications').then(() => { - disableNotificationsIfVisible(); - }); // Navigate to Application settings and Select Diagnostics cy.menu('Settings', 'Application Settings'); cy.get('.panel #control_diagnostics_accord .panel-title a') From c966ddcdc2a2acf223aaac11b60bae49fac55ac4 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 17:29:58 +0530 Subject: [PATCH 2/4] Enhanced collect-logs edit form test stability with additional intercepts and code reuse --- .../edit_collect_logs.cy.js | 380 +++++++++++------- 1 file changed, 230 insertions(+), 150 deletions(-) diff --git a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js index d71cd00c64b..c940b373eb4 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js @@ -1,51 +1,179 @@ /* eslint-disable no-undef */ -function resetProtocolForServer() { +const textConstants = { + // Menu options + settingsMenuOption: 'Settings', + appSettingsMenuOption: 'Application Settings', + + // List items + diagnosticsAccordionItem: 'Diagnostics', + diagnosticsAccordionItemId: 'diagnostics_accord', + manageIQRegionAccordItem: 'ManageIQ Region:', + zoneAccordItem: 'Zone:', + serverAccordItem: 'Server:', + + // Buttons + saveButton: 'Save', + cancelButton: 'Cancel', + resetButton: 'Reset', + + // Dropdown values + dropdownBlankValue: 'BLANK_VALUE', + sambaDropdownValue: 'FileDepotSmb', + + // Common selectors + buttonSelector: (type) => `#main-content .bx--btn-set button[type="${type}"]`, + + // Button types + submitButtonType: 'submit', + normalButtonType: 'button', + + // Component route url + componentRouteUrl: '/ops/explorer', + + // Flash message types + flashTypeSuccess: 'success', + + // Flash message text snippets + flashMessageSettingsSaved: 'saved', + flashMessageOperationCanceled: 'cancelled', +}; + +const { + diagnosticsAccordionItem, + dropdownBlankValue, + sambaDropdownValue, + saveButton, + cancelButton, + resetButton, + settingsMenuOption, + appSettingsMenuOption, + diagnosticsAccordionItemId, + manageIQRegionAccordItem, + zoneAccordItem, + serverAccordItem, + componentRouteUrl, + flashTypeSuccess, + flashMessageSettingsSaved, + flashMessageOperationCanceled, + buttonSelector, + submitButtonType, + normalButtonType, +} = textConstants; + +function interceptAndAwaitApi({ + alias, + method = 'POST', + urlPattern, + triggerFn, + currentApiIntercepts, +}) { + // If the alias is already registered, do not register it again + // This prevents multiple intercepts for the same API call + // which can lead to unexpected behavior in tests. + if (!currentApiIntercepts[alias]) { + cy.intercept(method, urlPattern).as(alias); + currentApiIntercepts[alias] = alias; + } + + triggerFn(); + + cy.wait(`@${alias}`); +} + +function invokeAndAwaitRegionInfo({ currentApiIntercepts }) { + interceptAndAwaitApi({ + alias: 'getRegionInfo', + urlPattern: /ops\/tree_select\?id=.*&text=.*ManageIQ.*Region.*Region.*/, + triggerFn: () => + cy.accordionItem( + manageIQRegionAccordItem, + true, + diagnosticsAccordionItemId + ), + currentApiIntercepts, + }); +} + +function invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }) { + interceptAndAwaitApi({ + alias: 'getZoneDefaultInfo', + urlPattern: + /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, + triggerFn: () => + cy.accordionItem(zoneAccordItem, true, diagnosticsAccordionItemId), + currentApiIntercepts, + }); +} + +function invokeAndAwaitServerInfo({ currentApiIntercepts }) { + interceptAndAwaitApi({ + alias: 'getServerInfo', + urlPattern: /ops\/tree_select\?id=.*&text=.*Server.*EVM.*(current).*/, + triggerFn: () => + cy.accordionItem(serverAccordItem, true, diagnosticsAccordionItemId), + currentApiIntercepts, + }); +} + +function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) { + interceptAndAwaitApi({ + alias: 'getCollectLogsTabInfo', + urlPattern: '/ops/change_tab?tab_id=diagnostics_collect_logs', + triggerFn: () => + cy + .get( + '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' + ) + .click(), + currentApiIntercepts, + }); +} + +function invokeAndAwaitEditEventForServer({ currentApiIntercepts }) { + interceptAndAwaitApi({ + alias: 'editEventForServer', + urlPattern: /\/ops\/x_button\/[^/]+\?pressed=.*log_depot_edit/, // matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints + triggerFn: () => + cy + .get( + '.miq-toolbar-actions .miq-toolbar-group button[id$="log_depot_edit"]' // matches both buttons log_depot_edit & zone_log_depot_edit + ) + .click(), + currentApiIntercepts, + }); +} + +function resetProtocolDropdown({ + currentApiIntercepts, + needsServerInfoFetch = true, +}) { // Select Diagnostics - cy.get('.panel #control_diagnostics_accord .panel-title a') - .contains('Diagnostics') - .click(); + cy.accordion(diagnosticsAccordionItem); // Open ManageIQ Region: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="ManageIQ Region:"]' - ).then(($li) => { - const span = $li.find('span.fa-angle-right'); - if (span.length) { - cy.wrap(span).click(); - } - }); + invokeAndAwaitRegionInfo({ currentApiIntercepts }); + // Open Zone: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Zone:"]' - ).then(($li) => { - const span = $li.find('span.fa-angle-right'); - if (span.length) { - cy.wrap(span).click(); - } - }); - // Selecting Server: list view - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Server:"]' - ).click(); + invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }); + + if (needsServerInfoFetch) { + // Selecting Server: list view + invokeAndAwaitServerInfo({ currentApiIntercepts }); + } // Selecting Collect Logs nav bar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); + invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }); // Clicking Edit button - cy.get( - '.miq-toolbar-actions .miq-toolbar-group button#log_depot_edit' - ).click(); - cy.wait('@editEventForServer'); + invokeAndAwaitEditEventForServer({ currentApiIntercepts }); + // Resetting Protocol dropdown value cy.get('#log-depot-settings .bx--select select#log_protocol').then( ($select) => { const currentValue = $select.val(); // If the value is not default one(BLANK_VALUE), then setting it to blank - if (currentValue !== 'BLANK_VALUE') { - cy.wrap($select).select('BLANK_VALUE'); - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') - .contains('Save') - .click(); + if (currentValue !== dropdownBlankValue) { + cy.wrap($select).select(dropdownBlankValue); + cy.contains(buttonSelector(submitButtonType), saveButton).click(); + // Validating confirmation flash message cy.get('#main_div #flash_msg_div .alert-success').contains( 'Log Depot Settings were saved' ); @@ -54,54 +182,20 @@ function resetProtocolForServer() { ); } -function resetProtocolForZone() { - cy.get('.panel #control_diagnostics_accord .panel-title a') - .contains('Diagnostics') - .click(); - // Open ManageIQ Region: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="ManageIQ Region:"]' - ).then(($li) => { - const span = $li.find('span.fa-angle-right'); - if (span.length) { - cy.wrap(span).click(); - } +function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) { + // Selecting Collect Logs nav bar + invokeAndAwaitCollectLogsTabInfo({ + currentApiIntercepts: registeredApiIntercepts, }); - // Open Zone: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Zone:"]' - ).click(); - // Selecting Collect Logs navbar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); // Clicking Edit button - cy.get( - '.miq-toolbar-actions .miq-toolbar-group button#zone_log_depot_edit' - ).click(); - cy.wait('@editEventForZone'); - // Resetting Protocol dropdown value - cy.get('#log-depot-settings .bx--select select#log_protocol').then( - ($select) => { - const currentValue = $select.val(); - // If the value is not default one(BLANK_VALUE), then setting it to blank and then saving - if (currentValue !== 'BLANK_VALUE') { - cy.wrap($select).select('BLANK_VALUE'); - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') - .contains('Save') - .click(); - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Log Depot Settings were saved' - ); - } - } - ); + invokeAndAwaitEditEventForServer({ + currentApiIntercepts: registeredApiIntercepts, + }); } function cancelButtonValidation() { // Click cancel button in the form - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="button"]') - .contains('Cancel') + cy.contains(buttonSelector(normalButtonType), cancelButton) .should('be.enabled') .click(); // Validating confirmation alert text displayed @@ -112,33 +206,36 @@ function cancelButtonValidation() { function resetButtonValidation() { // Confirm Reset button is disabled initially - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="button"]') - .contains('Reset') - .should('be.disabled'); + cy.contains(buttonSelector(normalButtonType), resetButton).should( + 'be.disabled' + ); + // Selecting Samba option from dropdown - cy.get('#log-depot-settings .bx--select select#log_protocol').select('Samba'); + cy.get('#log-depot-settings .bx--select select#log_protocol').select( + sambaDropdownValue + ); // Confirm Reset button is enabled once dropdown value is changed and then click on Reset - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="button"]') - .contains('Reset') + cy.contains(buttonSelector(normalButtonType), resetButton) .should('be.enabled') .click(); // Confirm dropdown has the old value cy.get('#log-depot-settings .bx--select select#log_protocol').should( 'have.value', - 'BLANK_VALUE' + dropdownBlankValue ); } function saveButtonValidation() { // Confirm Save button is disabled initially - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') - .contains('Save') - .should('be.disabled'); + cy.contains(buttonSelector(submitButtonType), saveButton).should( + 'be.disabled' + ); // Selecting Samba option from dropdown - cy.get('#log-depot-settings .bx--select select#log_protocol').select('Samba'); + cy.get('#log-depot-settings .bx--select select#log_protocol').select( + sambaDropdownValue + ); // Confirm Save button is enabled once dropdown value is changed and then click on Save - cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') - .contains('Save') + cy.contains(buttonSelector(submitButtonType), saveButton) .should('be.enabled') .click(); // Validating confirmation alert text displayed @@ -148,51 +245,36 @@ function saveButtonValidation() { } describe('Automate Collect logs Edit form operations', () => { + // Map that keeps track of registered API intercepts + // This is used to avoid registering the same API intercept multiple times + // during the test run, which can lead to unexpected behavior. + let registeredApiIntercepts; + beforeEach(() => { + registeredApiIntercepts = {}; cy.login(); // Navigate to Application settings and Select Diagnostics - cy.menu('Settings', 'Application Settings'); - cy.get('.panel #control_diagnostics_accord .panel-title a') - .contains('Diagnostics') - .click(); - // Open ManageIQ Region: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="ManageIQ Region:"]' - ).then(($li) => { - const span = $li.find('span.fa-angle-right'); - if (span.length) { - cy.wrap(span).click(); - } + cy.menu(settingsMenuOption, appSettingsMenuOption); + interceptAndAwaitApi({ + alias: 'getDiagnosticsInfo', + urlPattern: `/ops/accordion_select?id=${diagnosticsAccordionItemId}`, + triggerFn: () => cy.accordion(diagnosticsAccordionItem), + currentApiIntercepts: registeredApiIntercepts, }); }); describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Server > Collect logs > Edit', () => { beforeEach(() => { // Open Zone: - list view if not already open - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Zone:"]' - ).then(($li) => { - const span = $li.find('span.fa-angle-right'); - if (span.length) { - cy.wrap(span).click(); - } + invokeAndAwaitZoneDefaultInfo({ + currentApiIntercepts: registeredApiIntercepts, }); // Selecting Server: list view - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Server:"]' - ).click(); - // Selecting Collect Logs nav bar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); - // Clicking Edit button - cy.intercept('POST', '/ops/x_button/1?pressed=log_depot_edit').as( - 'editEventForServer' - ); - cy.get( - '.miq-toolbar-actions .miq-toolbar-group button#log_depot_edit' - ).click(); - cy.wait('@editEventForServer'); + invokeAndAwaitServerInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); + // Select collect logs navbar and open edit form + goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); }); it('Validate Cancel button', () => { @@ -210,12 +292,16 @@ describe('Automate Collect logs Edit form operations', () => { after(() => { cy?.url()?.then((url) => { // Ensures navigation to Settings -> Application-Settings in the UI - if (url?.includes('/ops/explorer')) { - resetProtocolForServer(); + if (url?.includes(componentRouteUrl)) { + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu('Settings', 'Application Settings'); - resetProtocolForServer(); + cy.menu(settingsMenuOption, appSettingsMenuOption); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + }); } }); }); @@ -224,23 +310,11 @@ describe('Automate Collect logs Edit form operations', () => { describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit', () => { beforeEach(() => { // Selecting Zone: - list view - cy.intercept('POST', '/ops/tree_select?id=z-2*').as('treeSelectApi'); - cy.get( - '#diagnostics_accord .treeview li.list-group-item[title^="Zone:"]' - ).click(); - cy.wait('@treeSelectApi'); - // Selecting Collect Logs navbar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); - // Clicking Edit button - cy.intercept('POST', '/ops/x_button/2?pressed=zone_log_depot_edit').as( - 'editEventForZone' - ); - cy.get( - '.miq-toolbar-actions .miq-toolbar-group button#zone_log_depot_edit' - ).click(); - cy.wait('@editEventForZone'); + invokeAndAwaitZoneDefaultInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); + // Select collect logs navbar and open edit form + goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); }); it('Validate Cancel button', () => { @@ -258,12 +332,18 @@ describe('Automate Collect logs Edit form operations', () => { after(() => { cy?.url()?.then((url) => { // Ensures navigation to Settings -> Application-Settings in the UI - if (url?.includes('/ops/explorer')) { - resetProtocolForZone(); + if (url?.includes(componentRouteUrl)) { + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + needsServerInfoFetch: false, + }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu('Settings', 'Application Settings'); - resetProtocolForZone(); + cy.menu(settingsMenuOption, appSettingsMenuOption); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + needsServerInfoFetch: false, + }); } }); }); From a3e98c3cf5193204896ef0211205842b0247f652 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 18:56:08 +0530 Subject: [PATCH 3/4] Replaced inline flash message checks with reusable expect_flash command --- .../edit_collect_logs.cy.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js index c940b373eb4..7f254ae1793 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js @@ -36,7 +36,7 @@ const textConstants = { // Flash message text snippets flashMessageSettingsSaved: 'saved', - flashMessageOperationCanceled: 'cancelled', + flashMessageOperationCanceled: 'cancel', }; const { @@ -174,9 +174,7 @@ function resetProtocolDropdown({ cy.wrap($select).select(dropdownBlankValue); cy.contains(buttonSelector(submitButtonType), saveButton).click(); // Validating confirmation flash message - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Log Depot Settings were saved' - ); + cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); } } ); @@ -198,10 +196,8 @@ function cancelButtonValidation() { cy.contains(buttonSelector(normalButtonType), cancelButton) .should('be.enabled') .click(); - // Validating confirmation alert text displayed - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Edit Log Depot settings was cancelled by the user' - ); + // Validating confirmation flash message + cy.expect_flash(flashTypeSuccess, flashMessageOperationCanceled); } function resetButtonValidation() { @@ -238,10 +234,8 @@ function saveButtonValidation() { cy.contains(buttonSelector(submitButtonType), saveButton) .should('be.enabled') .click(); - // Validating confirmation alert text displayed - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Log Depot Settings were saved' - ); + // Validating confirmation flash message + cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); } describe('Automate Collect logs Edit form operations', () => { From 3cb034a62f22203bd82dc0b5d346e7ed17c1fd1b Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Tue, 5 Aug 2025 22:46:25 +0530 Subject: [PATCH 4/4] Replaced accordionItem with selectAccordionItem --- .../edit_collect_logs.cy.js | 88 ++++++------------- 1 file changed, 26 insertions(+), 62 deletions(-) diff --git a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js index 7f254ae1793..8bd1c03b505 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/edit_collect_logs.cy.js @@ -8,9 +8,9 @@ const textConstants = { // List items diagnosticsAccordionItem: 'Diagnostics', diagnosticsAccordionItemId: 'diagnostics_accord', - manageIQRegionAccordItem: 'ManageIQ Region:', - zoneAccordItem: 'Zone:', - serverAccordItem: 'Server:', + manageIQRegionAccordItem: /^ManageIQ Region:/, + zoneAccordItem: /^Zone:/, + serverAccordItem: /^Server:/, // Buttons saveButton: 'Save', @@ -81,41 +81,6 @@ function interceptAndAwaitApi({ cy.wait(`@${alias}`); } -function invokeAndAwaitRegionInfo({ currentApiIntercepts }) { - interceptAndAwaitApi({ - alias: 'getRegionInfo', - urlPattern: /ops\/tree_select\?id=.*&text=.*ManageIQ.*Region.*Region.*/, - triggerFn: () => - cy.accordionItem( - manageIQRegionAccordItem, - true, - diagnosticsAccordionItemId - ), - currentApiIntercepts, - }); -} - -function invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }) { - interceptAndAwaitApi({ - alias: 'getZoneDefaultInfo', - urlPattern: - /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, - triggerFn: () => - cy.accordionItem(zoneAccordItem, true, diagnosticsAccordionItemId), - currentApiIntercepts, - }); -} - -function invokeAndAwaitServerInfo({ currentApiIntercepts }) { - interceptAndAwaitApi({ - alias: 'getServerInfo', - urlPattern: /ops\/tree_select\?id=.*&text=.*Server.*EVM.*(current).*/, - triggerFn: () => - cy.accordionItem(serverAccordItem, true, diagnosticsAccordionItemId), - currentApiIntercepts, - }); -} - function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getCollectLogsTabInfo', @@ -146,22 +111,17 @@ function invokeAndAwaitEditEventForServer({ currentApiIntercepts }) { function resetProtocolDropdown({ currentApiIntercepts, - needsServerInfoFetch = true, + selectServerListItem = true, }) { // Select Diagnostics cy.accordion(diagnosticsAccordionItem); - // Open ManageIQ Region: - list view if not already open - invokeAndAwaitRegionInfo({ currentApiIntercepts }); - - // Open Zone: - list view if not already open - invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }); + // Select "Zone:" or "Server:" accordion item + cy.selectAccordionItem([ + manageIQRegionAccordItem, + zoneAccordItem, + ...(selectServerListItem ? [serverAccordItem] : []), + ]); - if (needsServerInfoFetch) { - // Selecting Server: list view - invokeAndAwaitServerInfo({ currentApiIntercepts }); - } - // Selecting Collect Logs nav bar - invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }); // Clicking Edit button invokeAndAwaitEditEventForServer({ currentApiIntercepts }); @@ -259,14 +219,12 @@ describe('Automate Collect logs Edit form operations', () => { describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Server > Collect logs > Edit', () => { beforeEach(() => { - // Open Zone: - list view if not already open - invokeAndAwaitZoneDefaultInfo({ - currentApiIntercepts: registeredApiIntercepts, - }); - // Selecting Server: list view - invokeAndAwaitServerInfo({ - currentApiIntercepts: registeredApiIntercepts, - }); + // Select "Server:" accordion item + cy.selectAccordionItem([ + manageIQRegionAccordItem, + zoneAccordItem, + serverAccordItem, + ]); // Select collect logs navbar and open edit form goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); }); @@ -303,8 +261,13 @@ describe('Automate Collect logs Edit form operations', () => { describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit', () => { beforeEach(() => { - // Selecting Zone: - list view - invokeAndAwaitZoneDefaultInfo({ + // Select "Zone:" accordion item + interceptAndAwaitApi({ + alias: 'treeSelectApi', + urlPattern: + /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, + triggerFn: () => + cy.selectAccordionItem([manageIQRegionAccordItem, zoneAccordItem]), currentApiIntercepts: registeredApiIntercepts, }); // Select collect logs navbar and open edit form @@ -329,17 +292,18 @@ describe('Automate Collect logs Edit form operations', () => { if (url?.includes(componentRouteUrl)) { resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, - needsServerInfoFetch: false, + selectServerListItem: false, }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics cy.menu(settingsMenuOption, appSettingsMenuOption); resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, - needsServerInfoFetch: false, + selectServerListItem: false, }); } }); }); }); }); +