From 8e70ae37118060de807590f75f47db773bdbb194 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Thu, 7 Aug 2025 14:13:05 +0530 Subject: [PATCH 1/5] Replaced repeated element selectors with custom getter commands --- .../edit_collect_logs.cy.js | 68 ++++++++----------- 1 file changed, 27 insertions(+), 41 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 8bd1c03b505..93ed025c6c0 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 @@ -12,21 +12,23 @@ const textConstants = { zoneAccordItem: /^Zone:/, serverAccordItem: /^Server:/, + // Config options + editToolbarButton: 'Edit', + // Buttons saveButton: 'Save', cancelButton: 'Cancel', resetButton: 'Reset', + // Common element IDs + protocolSelectFieldId: 'log_protocol', + // 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', @@ -42,6 +44,7 @@ const textConstants = { const { diagnosticsAccordionItem, dropdownBlankValue, + editToolbarButton, sambaDropdownValue, saveButton, cancelButton, @@ -56,9 +59,8 @@ const { flashTypeSuccess, flashMessageSettingsSaved, flashMessageOperationCanceled, - buttonSelector, submitButtonType, - normalButtonType, + protocolSelectFieldId, } = textConstants; function interceptAndAwaitApi({ @@ -99,12 +101,7 @@ 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(), + triggerFn: () => cy.toolbar(editToolbarButton), currentApiIntercepts, }); } @@ -126,18 +123,16 @@ function resetProtocolDropdown({ 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 !== dropdownBlankValue) { - cy.wrap($select).select(dropdownBlankValue); - cy.contains(buttonSelector(submitButtonType), saveButton).click(); - // Validating confirmation flash message - cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); - } + cy.getFormSelectFieldById(protocolSelectFieldId).then(($select) => { + const currentValue = $select.val(); + // If the value is not default one(BLANK_VALUE), then setting it to blank + if (currentValue !== dropdownBlankValue) { + cy.wrap($select).select(dropdownBlankValue); + cy.getFormFooterButtonByType(saveButton, submitButtonType).click(); + // Validating confirmation flash message + cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); } - ); + }); } function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) { @@ -153,29 +148,21 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) { function cancelButtonValidation() { // Click cancel button in the form - cy.contains(buttonSelector(normalButtonType), cancelButton) - .should('be.enabled') - .click(); + cy.getFormFooterButtonByType(cancelButton).should('be.enabled').click(); // Validating confirmation flash message cy.expect_flash(flashTypeSuccess, flashMessageOperationCanceled); } function resetButtonValidation() { // Confirm Reset button is disabled initially - cy.contains(buttonSelector(normalButtonType), resetButton).should( - 'be.disabled' - ); + cy.getFormFooterButtonByType(resetButton).should('be.disabled'); // Selecting Samba option from dropdown - cy.get('#log-depot-settings .bx--select select#log_protocol').select( - sambaDropdownValue - ); + cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue); // Confirm Reset button is enabled once dropdown value is changed and then click on Reset - cy.contains(buttonSelector(normalButtonType), resetButton) - .should('be.enabled') - .click(); + cy.getFormFooterButtonByType(resetButton).should('be.enabled').click(); // Confirm dropdown has the old value - cy.get('#log-depot-settings .bx--select select#log_protocol').should( + cy.getFormSelectFieldById(protocolSelectFieldId).should( 'have.value', dropdownBlankValue ); @@ -183,15 +170,13 @@ function resetButtonValidation() { function saveButtonValidation() { // Confirm Save button is disabled initially - cy.contains(buttonSelector(submitButtonType), saveButton).should( + cy.getFormFooterButtonByType(saveButton, submitButtonType).should( 'be.disabled' ); // Selecting Samba option from dropdown - cy.get('#log-depot-settings .bx--select select#log_protocol').select( - sambaDropdownValue - ); + cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue); // Confirm Save button is enabled once dropdown value is changed and then click on Save - cy.contains(buttonSelector(submitButtonType), saveButton) + cy.getFormFooterButtonByType(saveButton, submitButtonType) .should('be.enabled') .click(); // Validating confirmation flash message @@ -207,6 +192,7 @@ describe('Automate Collect logs Edit form operations', () => { beforeEach(() => { registeredApiIntercepts = {}; cy.login(); + cy.wait(500); // Navigate to Application settings and Select Diagnostics cy.menu(settingsMenuOption, appSettingsMenuOption); interceptAndAwaitApi({ From ec99ce9de6af26faee1ed26e70460b454e1a407f Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Thu, 7 Aug 2025 14:55:02 +0530 Subject: [PATCH 2/5] Restructured after hooks --- .../edit_collect_logs.cy.js | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 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 93ed025c6c0..5271ad539ad 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 @@ -192,7 +192,6 @@ describe('Automate Collect logs Edit form operations', () => { beforeEach(() => { registeredApiIntercepts = {}; cy.login(); - cy.wait(500); // Navigate to Application settings and Select Diagnostics cy.menu(settingsMenuOption, appSettingsMenuOption); interceptAndAwaitApi({ @@ -228,20 +227,19 @@ describe('Automate Collect logs Edit form operations', () => { }); after(() => { - cy?.url()?.then((url) => { - // Ensures navigation to Settings -> Application-Settings in the UI - if (url?.includes(componentRouteUrl)) { + cy.url() + ?.then((url) => { + // Ensures navigation to Settings -> Application-Settings in the UI + if (!url?.includes(componentRouteUrl)) { + // Navigate to Settings -> Application-Settings before cleanup + cy.menu(settingsMenuOption, appSettingsMenuOption); + } + }) + .then(() => { resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, }); - } else { - // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu(settingsMenuOption, appSettingsMenuOption); - resetProtocolDropdown({ - currentApiIntercepts: registeredApiIntercepts, - }); - } - }); + }); }); }); @@ -273,22 +271,20 @@ describe('Automate Collect logs Edit form operations', () => { }); after(() => { - cy?.url()?.then((url) => { - // Ensures navigation to Settings -> Application-Settings in the UI - if (url?.includes(componentRouteUrl)) { + cy.url() + ?.then((url) => { + // Ensures navigation to Settings -> Application-Settings in the UI + if (!url?.includes(componentRouteUrl)) { + // Navigate to Settings -> Application-Settings before cleanup + cy.menu(settingsMenuOption, appSettingsMenuOption); + } + }) + .then(() => { resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, selectServerListItem: false, }); - } else { - // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu(settingsMenuOption, appSettingsMenuOption); - resetProtocolDropdown({ - currentApiIntercepts: registeredApiIntercepts, - selectServerListItem: false, - }); - } - }); + }); }); }); }); From 1b28afa998c7d1e1c87fe024dce4b2ebdc455dc2 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Fri, 8 Aug 2025 19:25:35 +0530 Subject: [PATCH 3/5] Added detailed component tests --- .../edit_collect_logs.cy.js | 50 ++++++++++++++++--- 1 file changed, 42 insertions(+), 8 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 5271ad539ad..6a345e06455 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 @@ -12,6 +12,10 @@ const textConstants = { zoneAccordItem: /^Zone:/, serverAccordItem: /^Server:/, + // Field values + formHeader: 'Editing Log Depot settings', + formSubheaderSnippet: 'Editing Log Depot Settings', + // Config options editToolbarButton: 'Edit', @@ -61,6 +65,8 @@ const { flashMessageOperationCanceled, submitButtonType, protocolSelectFieldId, + formHeader, + formSubheaderSnippet, } = textConstants; function interceptAndAwaitApi({ @@ -146,17 +152,41 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) { }); } +function validateFormElements() { + // Assert form header is visible + cy.expect_explorer_title(formHeader).should('be.visible'); + // Assert form sub-header is visible + cy.contains('#main-content .bx--form h3', formSubheaderSnippet).should( + 'be.visible' + ); + // Assert protocol field label is visible + cy.getFormLabelByInputId(protocolSelectFieldId).should('be.visible'); + // Assert protocol field is visible and enabled + cy.getFormSelectFieldById(protocolSelectFieldId) + .should('be.visible') + .and('be.enabled'); + // Assert cancel button is visible and enabled + cy.getFormFooterButtonByType(cancelButton) + .should('be.visible') + .and('be.enabled'); + // Assert save button is visible and disabled + cy.getFormFooterButtonByType(saveButton, submitButtonType) + .should('be.visible') + .and('be.disabled'); + // Assert reset button is visible and disabled + cy.getFormFooterButtonByType(resetButton) + .should('be.visible') + .and('be.disabled'); +} + function cancelButtonValidation() { // Click cancel button in the form - cy.getFormFooterButtonByType(cancelButton).should('be.enabled').click(); + cy.getFormFooterButtonByType(cancelButton).click(); // Validating confirmation flash message cy.expect_flash(flashTypeSuccess, flashMessageOperationCanceled); } function resetButtonValidation() { - // Confirm Reset button is disabled initially - cy.getFormFooterButtonByType(resetButton).should('be.disabled'); - // Selecting Samba option from dropdown cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue); // Confirm Reset button is enabled once dropdown value is changed and then click on Reset @@ -169,10 +199,6 @@ function resetButtonValidation() { } function saveButtonValidation() { - // Confirm Save button is disabled initially - cy.getFormFooterButtonByType(saveButton, submitButtonType).should( - 'be.disabled' - ); // Selecting Samba option from dropdown cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue); // Confirm Save button is enabled once dropdown value is changed and then click on Save @@ -214,6 +240,10 @@ describe('Automate Collect logs Edit form operations', () => { goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); }); + it('Validate form elements', () => { + validateFormElements(); + }); + it('Validate Cancel button', () => { cancelButtonValidation(); }); @@ -258,6 +288,10 @@ describe('Automate Collect logs Edit form operations', () => { goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); }); + it('Validate form elements', () => { + validateFormElements(); + }); + it('Validate Cancel button', () => { cancelButtonValidation(); }); From b610b33b397b52c92ca8f52a95fbc405cc85d4bb Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Mon, 18 Aug 2025 11:56:09 +0530 Subject: [PATCH 4/5] Minor refactor to improve readability --- .../edit_collect_logs.cy.js | 117 ++++++++++-------- 1 file changed, 63 insertions(+), 54 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 6a345e06455..17964abdf83 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,6 +1,10 @@ /* eslint-disable no-undef */ +import { flashClassMap } from "../../../../support/assertions/assertion_constants"; const textConstants = { + // Component route url + componentRouteUrl: '/ops/explorer', + // Menu options settingsMenuOption: 'Settings', appSettingsMenuOption: 'Application Settings', @@ -31,42 +35,48 @@ const textConstants = { dropdownBlankValue: 'BLANK_VALUE', sambaDropdownValue: 'FileDepotSmb', - // Button types - submitButtonType: 'submit', - - // Component route url - componentRouteUrl: '/ops/explorer', - - // Flash message types - flashTypeSuccess: 'success', - // Flash message text snippets flashMessageSettingsSaved: 'saved', - flashMessageOperationCanceled: 'cancel', + flashMessageOperationCancelled: 'cancel', }; const { - diagnosticsAccordionItem, - dropdownBlankValue, - editToolbarButton, - sambaDropdownValue, - saveButton, - cancelButton, - resetButton, + // Component route url + componentRouteUrl, + + // Menu options settingsMenuOption, appSettingsMenuOption, + + // List items + diagnosticsAccordionItem, diagnosticsAccordionItemId, manageIQRegionAccordItem, zoneAccordItem, serverAccordItem, - componentRouteUrl, - flashTypeSuccess, - flashMessageSettingsSaved, - flashMessageOperationCanceled, - submitButtonType, - protocolSelectFieldId, + + // Field values formHeader, formSubheaderSnippet, + + // Config options + editToolbarButton, + + // Buttons + saveButton, + cancelButton, + resetButton, + + // Common element IDs + protocolSelectFieldId, + + // Dropdown values + dropdownBlankValue, + sambaDropdownValue, + + // Flash message text snippets + flashMessageSettingsSaved, + flashMessageOperationCancelled, } = textConstants; function interceptAndAwaitApi({ @@ -89,7 +99,7 @@ function interceptAndAwaitApi({ cy.wait(`@${alias}`); } -function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) { +function goToCollectLogsTab({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getCollectLogsTabInfo', urlPattern: '/ops/change_tab?tab_id=diagnostics_collect_logs', @@ -103,10 +113,11 @@ function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) { }); } -function invokeAndAwaitEditEventForServer({ currentApiIntercepts }) { +function selectToolbarEditButton() { 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 + // This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints + urlPattern: /\/ops\/x_button\/[^/]+\?pressed=.*log_depot_edit/, triggerFn: () => cy.toolbar(editToolbarButton), currentApiIntercepts, }); @@ -126,28 +137,28 @@ function resetProtocolDropdown({ ]); // Clicking Edit button - invokeAndAwaitEditEventForServer({ currentApiIntercepts }); + selectToolbarEditButton({ currentApiIntercepts }); // Resetting Protocol dropdown value - cy.getFormSelectFieldById(protocolSelectFieldId).then(($select) => { - const currentValue = $select.val(); + cy.getFormSelectFieldById(protocolSelectFieldId).then((selectField) => { + const currentValue = selectField.val(); // If the value is not default one(BLANK_VALUE), then setting it to blank if (currentValue !== dropdownBlankValue) { - cy.wrap($select).select(dropdownBlankValue); - cy.getFormFooterButtonByType(saveButton, submitButtonType).click(); + cy.wrap(selectField).select(dropdownBlankValue); + cy.getFormFooterButtonByType(saveButton, 'submit').click(); // Validating confirmation flash message - cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); + cy.expect_flash(flashClassMap.success, flashMessageSettingsSaved); } }); } -function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) { - // Selecting Collect Logs nav bar - invokeAndAwaitCollectLogsTabInfo({ +function goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts) { + // Selecting Collect Logs tab + goToCollectLogsTab({ currentApiIntercepts: registeredApiIntercepts, }); // Clicking Edit button - invokeAndAwaitEditEventForServer({ + selectToolbarEditButton({ currentApiIntercepts: registeredApiIntercepts, }); } @@ -170,7 +181,7 @@ function validateFormElements() { .should('be.visible') .and('be.enabled'); // Assert save button is visible and disabled - cy.getFormFooterButtonByType(saveButton, submitButtonType) + cy.getFormFooterButtonByType(saveButton, 'submit') .should('be.visible') .and('be.disabled'); // Assert reset button is visible and disabled @@ -183,7 +194,7 @@ function cancelButtonValidation() { // Click cancel button in the form cy.getFormFooterButtonByType(cancelButton).click(); // Validating confirmation flash message - cy.expect_flash(flashTypeSuccess, flashMessageOperationCanceled); + cy.expect_flash(flashClassMap.success, flashMessageOperationCancelled); } function resetButtonValidation() { @@ -202,11 +213,11 @@ function saveButtonValidation() { // Selecting Samba option from dropdown cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue); // Confirm Save button is enabled once dropdown value is changed and then click on Save - cy.getFormFooterButtonByType(saveButton, submitButtonType) + cy.getFormFooterButtonByType(saveButton, 'submit') .should('be.enabled') .click(); // Validating confirmation flash message - cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); + cy.expect_flash(flashClassMap.success, flashMessageSettingsSaved); } describe('Automate Collect logs Edit form operations', () => { @@ -218,7 +229,7 @@ describe('Automate Collect logs Edit form operations', () => { beforeEach(() => { registeredApiIntercepts = {}; cy.login(); - // Navigate to Application settings and Select Diagnostics + // Navigate to Application settings and expand Diagnostics accordion cy.menu(settingsMenuOption, appSettingsMenuOption); interceptAndAwaitApi({ alias: 'getDiagnosticsInfo', @@ -237,19 +248,18 @@ describe('Automate Collect logs Edit form operations', () => { serverAccordItem, ]); // Select collect logs navbar and open edit form - goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); + goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts); }); it('Validate form elements', () => { validateFormElements(); }); - it('Validate Cancel button', () => { - cancelButtonValidation(); - }); - - it('Validate Reset button', () => { + it('Validate Reset & Cancel buttons', () => { + // Reset button validation resetButtonValidation(); + // Cancel button validation + cancelButtonValidation(); }); it('Validate Save button', () => { @@ -284,20 +294,19 @@ describe('Automate Collect logs Edit form operations', () => { cy.selectAccordionItem([manageIQRegionAccordItem, zoneAccordItem]), currentApiIntercepts: registeredApiIntercepts, }); - // Select collect logs navbar and open edit form - goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts); + // Select collect logs tab and open edit form + goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts); }); it('Validate form elements', () => { validateFormElements(); }); - it('Validate Cancel button', () => { - cancelButtonValidation(); - }); - - it('Validate Reset button', () => { + it('Validate Reset & Cancel buttons', () => { + // Reset button validation resetButtonValidation(); + // Cancel button validation + cancelButtonValidation(); }); it('Validate Save button', () => { From 1ba688b60044390da797b6149db2be097ad1976d Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Mon, 18 Aug 2025 12:06:43 +0530 Subject: [PATCH 5/5] Applied interceptApi command --- .../edit_collect_logs.cy.js | 71 ++++--------------- 1 file changed, 14 insertions(+), 57 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 17964abdf83..fd335f44d07 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 @@ -79,28 +79,8 @@ const { flashMessageOperationCancelled, } = 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 goToCollectLogsTab({ currentApiIntercepts }) { - interceptAndAwaitApi({ +function goToCollectLogsTab() { + cy.interceptApi({ alias: 'getCollectLogsTabInfo', urlPattern: '/ops/change_tab?tab_id=diagnostics_collect_logs', triggerFn: () => @@ -109,24 +89,19 @@ function goToCollectLogsTab({ currentApiIntercepts }) { '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' ) .click(), - currentApiIntercepts, }); } function selectToolbarEditButton() { - interceptAndAwaitApi({ + cy.interceptApi({ alias: 'editEventForServer', // This pattern matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints urlPattern: /\/ops\/x_button\/[^/]+\?pressed=.*log_depot_edit/, triggerFn: () => cy.toolbar(editToolbarButton), - currentApiIntercepts, }); } -function resetProtocolDropdown({ - currentApiIntercepts, - selectServerListItem = true, -}) { +function resetProtocolDropdown({ selectServerListItem = true } = {}) { // Select Diagnostics cy.accordion(diagnosticsAccordionItem); // Select "Zone:" or "Server:" accordion item @@ -137,7 +112,7 @@ function resetProtocolDropdown({ ]); // Clicking Edit button - selectToolbarEditButton({ currentApiIntercepts }); + selectToolbarEditButton(); // Resetting Protocol dropdown value cy.getFormSelectFieldById(protocolSelectFieldId).then((selectField) => { @@ -152,15 +127,11 @@ function resetProtocolDropdown({ }); } -function goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts) { +function goToCollectLogsTabAndOpenEditForm() { // Selecting Collect Logs tab - goToCollectLogsTab({ - currentApiIntercepts: registeredApiIntercepts, - }); + goToCollectLogsTab(); // Clicking Edit button - selectToolbarEditButton({ - currentApiIntercepts: registeredApiIntercepts, - }); + selectToolbarEditButton(); } function validateFormElements() { @@ -221,21 +192,14 @@ 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 expand Diagnostics accordion cy.menu(settingsMenuOption, appSettingsMenuOption); - interceptAndAwaitApi({ + cy.interceptApi({ alias: 'getDiagnosticsInfo', urlPattern: `/ops/accordion_select?id=${diagnosticsAccordionItemId}`, triggerFn: () => cy.accordion(diagnosticsAccordionItem), - currentApiIntercepts: registeredApiIntercepts, }); }); @@ -248,7 +212,7 @@ describe('Automate Collect logs Edit form operations', () => { serverAccordItem, ]); // Select collect logs navbar and open edit form - goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts); + goToCollectLogsTabAndOpenEditForm(); }); it('Validate form elements', () => { @@ -276,9 +240,7 @@ describe('Automate Collect logs Edit form operations', () => { } }) .then(() => { - resetProtocolDropdown({ - currentApiIntercepts: registeredApiIntercepts, - }); + resetProtocolDropdown(); }); }); }); @@ -286,16 +248,15 @@ describe('Automate Collect logs Edit form operations', () => { describe('Settings > Application Settings > Diagnostics > Manage IQ Region > Zone > Collect logs > Edit', () => { beforeEach(() => { // Select "Zone:" accordion item - interceptAndAwaitApi({ + cy.interceptApi({ alias: 'treeSelectApi', urlPattern: /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, triggerFn: () => cy.selectAccordionItem([manageIQRegionAccordItem, zoneAccordItem]), - currentApiIntercepts: registeredApiIntercepts, }); // Select collect logs tab and open edit form - goToCollectLogsTabAndOpenEditForm(registeredApiIntercepts); + goToCollectLogsTabAndOpenEditForm(); }); it('Validate form elements', () => { @@ -323,12 +284,8 @@ describe('Automate Collect logs Edit form operations', () => { } }) .then(() => { - resetProtocolDropdown({ - currentApiIntercepts: registeredApiIntercepts, - selectServerListItem: false, - }); + resetProtocolDropdown({ selectServerListItem: false }); }); }); }); }); -