From 1d5b2a81ce1bf11edc9e39a02de43b3c7b47a6e9 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 16:57:38 +0530 Subject: [PATCH 1/5] Enhanced accordionItem comand to allow partial match and expand nested options --- cypress/support/commands/explorer.js | 32 +++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/cypress/support/commands/explorer.js b/cypress/support/commands/explorer.js index 777d3bd7158..523cd18410b 100644 --- a/cypress/support/commands/explorer.js +++ b/cypress/support/commands/explorer.js @@ -18,9 +18,35 @@ Cypress.Commands.add('accordion', (title) => { return ret.parents('.panel'); }); -// name: String of the record in the accordion panel to click. -Cypress.Commands.add('accordionItem', (name) => { +/** + * name: String of the record in the accordion panel to click. + * partialMatch: Boolean to indicate if the name should be matched partially. + * parentAccordId: Optional ID of the parent accordion to scope the search. + * If provided, the search will be limited to items within that accordion. + */ +Cypress.Commands.add('accordionItem', (name, partialMatch = false, parentAccordId) => { cy.get('#main-content'); // ensure screen loads first - cy.get('.list-group-item').contains(name).click(); + const selector = parentAccordId + ? `.sidebar-pf-left #${parentAccordId} .list-group-item` + : '.sidebar-pf-left .list-group-item'; + cy.get(selector).each(($el) => { + const text = $el.text().trim(); + const isMatch = partialMatch + ? text.toLowerCase().includes(name.toLowerCase()) + : text === name; + + if (isMatch) { + const span = $el.find('span.fa-angle-right'); + if (span.length) { + cy.wrap(span).click({ force: true }); + } else { + cy.wrap($el).click({ force: true }); + } + + // Stop looping after finding and clicking the matching item + return false; + } + return true; // continue looping + }); }); From 4c5fd1e9797ceef71d4f7aa9493cb245b9486c09 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 17:25:44 +0530 Subject: [PATCH 2/5] 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 e9b091ea5c436166e23d7c3ee0d93eb3810e88c7 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 17:29:58 +0530 Subject: [PATCH 3/5] Enhanced collect-logs edit form test stability with additional intercepts and code reuse --- .../edit_collect_logs.cy.js | 335 +++++++++++------- 1 file changed, 208 insertions(+), 127 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..225371d5f63 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,90 +1,169 @@ /* eslint-disable no-undef */ -function resetProtocolForServer() { - // Select Diagnostics - 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(); - } +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', + + // 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, +} = 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('ManageIQ Region:', true, 'diagnostics_accord'), + 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(); - } +} + +function invokeAndAwaitZoneDefaultInfo({ + currentApiIntercepts, +}) { + interceptAndAwaitApi({ + alias: 'getZoneDefaultInfo', + urlPattern: + /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, + triggerFn: () => cy.accordionItem('Zone:', true, 'diagnostics_accord'), + currentApiIntercepts, }); - // 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.get( - '.miq-toolbar-actions .miq-toolbar-group button#log_depot_edit' - ).click(); - cy.wait('@editEventForServer'); - // 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(); - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Log Depot Settings were saved' - ); - } - } - ); } -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 invokeAndAwaitServerInfo({ + currentApiIntercepts, +}) { + interceptAndAwaitApi({ + alias: 'getServerInfo', + urlPattern: /ops\/tree_select\?id=.*&text=.*Server.*EVM.*(current).*/, + triggerFn: () => cy.accordionItem('Server:', true, 'diagnostics_accord'), + 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.accordion(diagnosticsAccordionItem); + // Open ManageIQ Region: - list view if not already open + invokeAndAwaitRegionInfo({ currentApiIntercepts }); + // 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(); + invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }); + + if (needsServerInfoFetch) { + // Selecting Server: list view + invokeAndAwaitServerInfo({ currentApiIntercepts }); + } + // Selecting Collect Logs nav bar + invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }); // Clicking Edit button - cy.get( - '.miq-toolbar-actions .miq-toolbar-group button#zone_log_depot_edit' - ).click(); - cy.wait('@editEventForZone'); + 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 and then saving + // 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"]') @@ -116,7 +195,9 @@ function resetButtonValidation() { .contains('Reset') .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( + 'FileDepotSmb' + ); // 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') @@ -135,7 +216,9 @@ function saveButtonValidation() { .contains('Save') .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( + 'FileDepotSmb' + ); // 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') @@ -148,51 +231,45 @@ 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, }); + // Open ManageIQ Region: - list view if not already open + invokeAndAwaitRegionInfo({ 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(); + invokeAndAwaitServerInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); // Selecting Collect Logs nav bar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); + invokeAndAwaitCollectLogsTabInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); + // 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'); + invokeAndAwaitEditEventForServer({ + currentApiIntercepts: registeredApiIntercepts, + }); }); it('Validate Cancel button', () => { @@ -211,11 +288,15 @@ describe('Automate Collect logs Edit form operations', () => { cy?.url()?.then((url) => { // Ensures navigation to Settings -> Application-Settings in the UI if (url?.includes('/ops/explorer')) { - resetProtocolForServer(); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics cy.menu('Settings', 'Application Settings'); - resetProtocolForServer(); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + }); } }); }); @@ -224,23 +305,17 @@ 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'); + invokeAndAwaitZoneDefaultInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); // Selecting Collect Logs navbar - cy.get( - '#tab_all_tabs_div #ops_tabs .nav-tabs li#diagnostics_collect_logs_tab' - ).click(); + invokeAndAwaitCollectLogsTabInfo({ + currentApiIntercepts: registeredApiIntercepts, + }); // 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'); + invokeAndAwaitEditEventForServer({ + currentApiIntercepts: registeredApiIntercepts, + }); }); it('Validate Cancel button', () => { @@ -259,11 +334,17 @@ describe('Automate Collect logs Edit form operations', () => { cy?.url()?.then((url) => { // Ensures navigation to Settings -> Application-Settings in the UI if (url?.includes('/ops/explorer')) { - resetProtocolForZone(); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + needsServerInfoFetch: false, + }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics cy.menu('Settings', 'Application Settings'); - resetProtocolForZone(); + resetProtocolDropdown({ + currentApiIntercepts: registeredApiIntercepts, + needsServerInfoFetch: false, + }); } }); }); From 7d745ac9bf4eb18262f750bcb306ac37e4d4e908 Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 18:38:47 +0530 Subject: [PATCH 4/5] Defined a constants object for static strings to reduce duplication --- .../edit_collect_logs.cy.js | 62 +++++++++---------- 1 file changed, 29 insertions(+), 33 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 225371d5f63..09a67295ba9 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 @@ -71,44 +71,42 @@ function interceptAndAwaitApi({ cy.wait(`@${alias}`); } -function invokeAndAwaitRegionInfo({ - currentApiIntercepts, -}) { +function invokeAndAwaitRegionInfo({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getRegionInfo', urlPattern: /ops\/tree_select\?id=.*&text=.*ManageIQ.*Region.*Region.*/, triggerFn: () => - cy.accordionItem('ManageIQ Region:', true, 'diagnostics_accord'), + cy.accordionItem( + manageIQRegionAccordItem, + true, + diagnosticsAccordionItemId + ), currentApiIntercepts, }); } -function invokeAndAwaitZoneDefaultInfo({ - currentApiIntercepts, -}) { +function invokeAndAwaitZoneDefaultInfo({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getZoneDefaultInfo', urlPattern: /ops\/tree_select\?id=.*&text=.*Zone.*Default.*Zone.*(current).*/, - triggerFn: () => cy.accordionItem('Zone:', true, 'diagnostics_accord'), + triggerFn: () => + cy.accordionItem(zoneAccordItem, true, diagnosticsAccordionItemId), currentApiIntercepts, }); } -function invokeAndAwaitServerInfo({ - currentApiIntercepts, -}) { +function invokeAndAwaitServerInfo({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getServerInfo', urlPattern: /ops\/tree_select\?id=.*&text=.*Server.*EVM.*(current).*/, - triggerFn: () => cy.accordionItem('Server:', true, 'diagnostics_accord'), + triggerFn: () => + cy.accordionItem(serverAccordItem, true, diagnosticsAccordionItemId), currentApiIntercepts, }); } -function invokeAndAwaitCollectLogsTabInfo({ - currentApiIntercepts, -}) { +function invokeAndAwaitCollectLogsTabInfo({ currentApiIntercepts }) { interceptAndAwaitApi({ alias: 'getCollectLogsTabInfo', urlPattern: '/ops/change_tab?tab_id=diagnostics_collect_logs', @@ -122,9 +120,7 @@ function invokeAndAwaitCollectLogsTabInfo({ }); } -function invokeAndAwaitEditEventForServer({ - 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 @@ -164,10 +160,10 @@ function resetProtocolDropdown({ ($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'); + if (currentValue !== dropdownBlankValue) { + cy.wrap($select).select(dropdownBlankValue); cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') - .contains('Save') + .contains(saveButton) .click(); cy.get('#main_div #flash_msg_div .alert-success').contains( 'Log Depot Settings were saved' @@ -180,7 +176,7 @@ function resetProtocolDropdown({ function cancelButtonValidation() { // Click cancel button in the form cy.get('#diagnostics_collect_logs .bx--btn-set button[type="button"]') - .contains('Cancel') + .contains(cancelButton) .should('be.enabled') .click(); // Validating confirmation alert text displayed @@ -192,36 +188,36 @@ function cancelButtonValidation() { function resetButtonValidation() { // Confirm Reset button is disabled initially cy.get('#diagnostics_collect_logs .bx--btn-set button[type="button"]') - .contains('Reset') + .contains(resetButton) .should('be.disabled'); // Selecting Samba option from dropdown cy.get('#log-depot-settings .bx--select select#log_protocol').select( - 'FileDepotSmb' + 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') + .contains(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') + .contains(saveButton) .should('be.disabled'); // Selecting Samba option from dropdown cy.get('#log-depot-settings .bx--select select#log_protocol').select( - 'FileDepotSmb' + 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') + .contains(saveButton) .should('be.enabled') .click(); // Validating confirmation alert text displayed @@ -287,13 +283,13 @@ 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')) { + if (url?.includes(componentRouteUrl)) { resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu('Settings', 'Application Settings'); + cy.menu(settingsMenuOption, appSettingsMenuOption); resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, }); @@ -333,14 +329,14 @@ 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')) { + if (url?.includes(componentRouteUrl)) { resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, needsServerInfoFetch: false, }); } else { // Navigate to Settings -> Application-Settings before selecting Diagnostics - cy.menu('Settings', 'Application Settings'); + cy.menu(settingsMenuOption, appSettingsMenuOption); resetProtocolDropdown({ currentApiIntercepts: registeredApiIntercepts, needsServerInfoFetch: false, From a5142fdcef1a6f04692847d300a58e356b3d767f Mon Sep 17 00:00:00 2001 From: asirvadAbrahamVarghese Date: Wed, 9 Jul 2025 18:56:08 +0530 Subject: [PATCH 5/5] Replaced inline flash message checks with reusable expect_flash command --- .../edit_collect_logs.cy.js | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 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 09a67295ba9..85b327610da 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 @@ -165,9 +165,8 @@ function resetProtocolDropdown({ cy.get('#diagnostics_collect_logs .bx--btn-set button[type="Submit"]') .contains(saveButton) .click(); - cy.get('#main_div #flash_msg_div .alert-success').contains( - 'Log Depot Settings were saved' - ); + // Validating confirmation flash message + cy.expect_flash(flashTypeSuccess, flashMessageSettingsSaved); } } ); @@ -179,10 +178,8 @@ function cancelButtonValidation() { .contains(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() { @@ -220,10 +217,8 @@ function saveButtonValidation() { .contains(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', () => {