diff --git a/cypress/README.md b/cypress/README.md index 8bfc738bd85..2ae9d948176 100644 --- a/cypress/README.md +++ b/cypress/README.md @@ -82,7 +82,7 @@ ManageIQ implements the following cypress extensions: ##### element_selectors -* `cy.getFormFooterButtonByTypeWithText({ buttonType, buttonText, buttonWrapperClass })` - retrieves form footer button by its name and type. `buttonText` is the name or text content of the button. `buttonType` is the HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'. `buttonWrapperClass` is the CSS class of the wrapper element containing the buttons. Defaults to 'bx--btn-set'. e.g. `cy.getFormFooterButtonByTypeWithText({buttonText: 'Cancel'});`, `cy.getFormFooterButtonByTypeWithText({buttonText: 'Submit', buttonType: 'submit'});`, `cy.getFormFooterButtonByTypeWithText({buttonText: 'Save', buttonWrapperClass: 'custom-wrapper'});` +* `cy.getFormButtonByTypeWithText({ buttonType, buttonText })` - retrieves form footer button by its name and type. `buttonText` is the name or text content of the button. `buttonType` is the HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'. e.g. `cy.getFormButtonByTypeWithText({buttonText: 'Cancel'});`, `cy.getFormButtonByTypeWithText({buttonText: 'Submit', buttonType: 'submit'});` * `cy.getFormInputFieldByIdAndType({ inputId, inputType })` - retrieves a form input field by its ID and type. `inputId` is the ID of the input field. `inputType` is the HTML input type (e.g., 'text', 'email', 'password'). Defaults to 'text'. e.g. `cy.getFormInputFieldByIdAndType({inputId: 'name'});`, `cy.getFormInputFieldByIdAndType({inputId: 'name', inputType: 'text'});` * `cy.getFormLabelByForAttribute({ forValue })` - retrieves a form label associated with a specific input field by its 'for' attribute. `forValue` is the value of the 'for' attribute that matches the input field's ID. e.g. `cy.getFormLabelByForAttribute({forValue: 'name'});` * `cy.getFormLegendByText({ legendText })` - retrieves a form legend element by its text content. Legend elements are typically used as captions for fieldset elements in forms. `legendText` is the text content of the legend element. e.g. `cy.getFormLegendByText({legendText: 'Basic Information'});` @@ -93,7 +93,7 @@ ManageIQ implements the following cypress extensions: * `cy.validateFormLabels(labelConfigs)` - validates form field labels based on provided configurations. `labelConfigs` is an array of label configuration objects with properties: `forValue` (required) - the 'for' attribute value of the label, `expectedText` (optional) - the expected text content of the label. e.g. `cy.validateFormLabels([{ forValue: 'name', expectedText: 'Name' }, { forValue: 'email', expectedText: 'Email Address' }]);` or using constants: `cy.validateFormLabels([{ [LABEL_CONFIG_KEYS.FOR_VALUE]: 'name', [LABEL_CONFIG_KEYS.EXPECTED_TEXT]: 'Name' }]);` * `cy.validateFormFields(fieldConfigs)` - validates form input fields based on provided configurations. `fieldConfigs` is an array of field configuration objects with properties: `id` (required) - the ID of the form field, `fieldType` (optional, default: 'input') - the type of field ('input', 'select', 'textarea'), `inputFieldType` (optional, default: 'text') - the type of input field ('text', 'password', 'number'), `shouldBeDisabled` (optional, default: false) - whether the field should be disabled, `expectedValue` (optional) - the expected value of the field. e.g. `cy.validateFormFields([{ id: 'name', shouldBeDisabled: true }, { id: 'role', fieldType: 'select', expectedValue: 'admin' }]);` or using constants: `cy.validateFormFields([{ [FIELD_CONFIG_KEYS.ID]: 'email', [FIELD_CONFIG_KEYS.INPUT_FIELD_TYPE]: 'email' }, { [FIELD_CONFIG_KEYS.ID]: 'name', [FIELD_CONFIG_KEYS.SHOULD_BE_DISABLED]: true }]);` -* `cy.validateFormFooterButtons(buttonConfigs)` - validates form buttons based on provided configurations. `buttonConfigs` is an array of button configuration objects with properties: `buttonText` (required) - the text of the button, `buttonType` (optional, default: 'button') - the type of button (e.g., 'submit', 'reset'), `shouldBeDisabled` (optional, default: false) - whether the button should be disabled, `buttonWrapperClass` (optional, default: 'bx--btn-set') - the CSS class of the wrapper element containing the buttons. e.g. `cy.validateFormFooterButtons([{ buttonText: 'Cancel' }, { buttonText: 'Submit', buttonType: 'submit', shouldBeDisabled: true }]);`, `cy.validateFormFooterButtons([{ buttonText: 'Save', buttonWrapperClass: 'custom-wrapper' }]);` or using constants: `cy.validateFormFooterButtons([{ [BUTTON_CONFIG_KEYS.TEXT]: 'Cancel', [BUTTON_CONFIG_KEYS.BUTTON_WRAPPER_CLASS]: 'custom-button-wrapper' }]);` +* `cy.validateFormButtons(buttonConfigs)` - validates form buttons based on provided configurations. `buttonConfigs` is an array of button configuration objects with properties: `buttonText` (required) - the text of the button, `buttonType` (optional, default: 'button') - the type of button (e.g., 'submit', 'reset'), `shouldBeDisabled` (optional, default: false) - whether the button should be disabled. e.g. `cy.validateFormButtons([{ buttonText: 'Cancel' }, { buttonText: 'Submit', buttonType: 'submit', shouldBeDisabled: true }]);` or using constants: `cy.validateFormButtons([{ [BUTTON_CONFIG_KEYS.TEXT]: 'Cancel', [BUTTON_CONFIG_KEYS.BUTTON_WRAPPER_CLASS]: 'custom-button-wrapper' }]);` #### Assertions diff --git a/cypress/e2e/ui/Automation/Embedded-Automate/Explorer/namespace.cy.js b/cypress/e2e/ui/Automation/Embedded-Automate/Explorer/namespace.cy.js index ee98de9981e..a23a4859182 100644 --- a/cypress/e2e/ui/Automation/Embedded-Automate/Explorer/namespace.cy.js +++ b/cypress/e2e/ui/Automation/Embedded-Automate/Explorer/namespace.cy.js @@ -59,7 +59,7 @@ function addDomainOrNamespace({ nameFieldValue }) { urlPattern: '/miq_ae_class/create_namespace/new?button=add', triggerFn: () => cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText: ADD_BUTTON_TEXT, buttonType: 'submit', }) @@ -92,17 +92,17 @@ function validateNamespaceFormFields(isEditForm = false) { cy.getFormInputFieldByIdAndType({ inputId: 'description' }) .should('be.visible') .and('be.enabled'); - cy.getFormFooterButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) .should('be.visible') .and('be.enabled'); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: isEditForm ? SAVE_BUTTON_TEXT : ADD_BUTTON_TEXT, buttonType: 'submit', }) .should('be.visible') .and('be.disabled'); if (isEditForm) { - cy.getFormFooterButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) .should('be.visible') .and('be.disabled'); } @@ -142,14 +142,14 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> it('Validate Add Namespace form fields', () => { cy.toolbar(TOOLBAR_CONFIGURATION, TOOLBAR_ADD_NEW_NAMESPACE); validateNamespaceFormFields(); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); }); it('Validate Cancel button', () => { cy.toolbar(TOOLBAR_CONFIGURATION, TOOLBAR_ADD_NEW_NAMESPACE); - cy.getFormFooterButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) .should('be.enabled') .click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_CANCELLED); @@ -159,7 +159,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> cy.toolbar(TOOLBAR_CONFIGURATION, TOOLBAR_ADD_NEW_NAMESPACE); addDomainOrNamespace({ nameFieldValue: INVALID_NAMESPACE_NAME }); cy.expect_flash(flashClassMap.error, FLASH_MESSAGE_INVALID_NAMESPACE); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); }); @@ -167,7 +167,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> it('Validate Edit Namespace form fields', () => { createNamespaceAndOpenEditForm(); validateNamespaceFormFields(true); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); }); @@ -182,14 +182,14 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> NAMESPACE_NAME, ]); cy.toolbar(TOOLBAR_CONFIGURATION, TOOLBAR_EDIT_NAMESPACE); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }).should('be.disabled'); cy.getFormInputFieldByIdAndType({ inputId: 'description' }) .clear() .type(EDITED_DESCRIPTION); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) @@ -211,7 +211,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> cy.toolbar(TOOLBAR_CONFIGURATION, TOOLBAR_ADD_NEW_NAMESPACE); addDomainOrNamespace({ nameFieldValue: NAMESPACE_NAME }); cy.expect_flash(flashClassMap.error, FLASH_MESSAGE_NAME_ALREADY_EXISTS); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); }); @@ -219,7 +219,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> it('Checking whether Cancel & Reset buttons work fine in the Edit form', () => { createNamespaceAndOpenEditForm(); /* Validating Reset button */ - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, }).should('be.disabled'); cy.getFormInputFieldByIdAndType({ inputId: 'name' }) @@ -228,7 +228,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> cy.getFormInputFieldByIdAndType({ inputId: 'description' }) .clear() .type(EDITED_DESCRIPTION); - cy.getFormFooterButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) .should('be.enabled') .click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_RESET_NAMESPACE); @@ -241,7 +241,7 @@ describe('Automate operations on Namespaces: Automation -> Embedded Automate -> DESCRIPTION ); /* Validating Cancel button */ - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_CANCELLED); diff --git a/cypress/e2e/ui/Services/Catalogs/catalog.cy.js b/cypress/e2e/ui/Services/Catalogs/catalog.cy.js index b31eb2d301c..c817c745e11 100644 --- a/cypress/e2e/ui/Services/Catalogs/catalog.cy.js +++ b/cypress/e2e/ui/Services/Catalogs/catalog.cy.js @@ -87,7 +87,7 @@ function validateElements({ isEditForm }) { }, ]); // Validate form footer buttons - cy.validateFormFooterButtons([ + cy.validateFormButtons([ { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: isEditForm ? SAVE_BUTTON_TEXT @@ -156,7 +156,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con // Validate elements validateElements({ isEditForm: false }); // Cancel - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_CANCELLED); @@ -174,7 +174,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con actionType: DUAL_LIST_ACTION_TYPE.ADD, optionsToSelect: [CATALOG_ITEM_NAME_1], }); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: ADD_BUTTON_TEXT, buttonType: 'submit', }).click(); @@ -185,7 +185,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con cy.getFormInputFieldByIdAndType({ inputId: 'description' }).type( '-Updated' ); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }).click(); @@ -214,7 +214,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con actionType: DUAL_LIST_ACTION_TYPE.ADD, optionsToSelect: [CATALOG_ITEM_NAME_1], }); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: ADD_BUTTON_TEXT, buttonType: 'submit', }).click(); @@ -230,7 +230,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con cy.getFormInputFieldByIdAndType({ inputId: 'description' }).type( '-Updated' ); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_RESET); @@ -239,7 +239,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con TEST_DESCRIPTION ); // Cancel - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_CANCELLED); diff --git a/cypress/e2e/ui/Services/Catalogs/copy_catalog.cy.js b/cypress/e2e/ui/Services/Catalogs/copy_catalog.cy.js index 37cc117602b..2246dd5c14f 100644 --- a/cypress/e2e/ui/Services/Catalogs/copy_catalog.cy.js +++ b/cypress/e2e/ui/Services/Catalogs/copy_catalog.cy.js @@ -95,7 +95,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con [FIELD_CONFIG_KEYS.INPUT_FIELD_TYPE]: 'checkbox', }, ]); - cy.validateFormFooterButtons([ + cy.validateFormButtons([ { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: ADD_BUTTON_TEXT, [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit', @@ -105,7 +105,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con }, ]); // Cancel - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_CANCELLED); @@ -128,7 +128,7 @@ describe('Automate Catalog form operations: Services > Catalogs > Catalogs > Con cy.getFormLabelByForAttribute({ forValue: 'copy_tags', }).click(); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: ADD_BUTTON_TEXT, buttonType: 'submit', }).click(); diff --git a/cypress/e2e/ui/Settings/Application-Settings/c_and_u_gap_collection.cy.js b/cypress/e2e/ui/Settings/Application-Settings/c_and_u_gap_collection.cy.js index 89d67d7fc20..79cbd7d7e32 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/c_and_u_gap_collection.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/c_and_u_gap_collection.cy.js @@ -52,7 +52,7 @@ function saveFormAndAssertFlashMessage(flashMessageType, flashMessage) { urlPattern: '/ops/cu_repair?button=submit', triggerFn: () => cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText: 'Save', buttonType: 'submit', }) @@ -106,7 +106,7 @@ describe('Automate C & U Gap Collection form operations: Settings > Application { [FIELD_CONFIG_KEYS.ID]: 'endDate' }, ]); // Validate form footer buttons - cy.validateFormFooterButtons([ + cy.validateFormButtons([ { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Save', [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit', 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 d50796b7d6d..e5bdb5f3a24 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,7 +71,7 @@ function resetProtocolDropdown({ selectServerListItem = true } = {}) { // If the value is not default one(BLANK_VALUE), then setting it to blank if (currentValue !== DROPDOWN_BLANK_VALUE) { cy.wrap(selectField).select(DROPDOWN_BLANK_VALUE); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }).click(); @@ -105,20 +105,20 @@ function validateFormElements() { .should('be.visible') .and('be.enabled'); // Assert cancel button is visible and enabled - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }) .should('be.visible') .and('be.enabled'); // Assert save button is visible and disabled - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) .should('be.visible') .and('be.disabled'); // Assert reset button is visible and disabled - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, }) .should('be.visible') @@ -127,7 +127,7 @@ function validateFormElements() { function cancelButtonValidation() { // Click cancel button in the form - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); // Validating confirmation flash message @@ -140,7 +140,7 @@ function resetButtonValidation() { SAMBA_DROPDOWN_VALUE ); // Confirm Reset button is enabled once dropdown value is changed and then click on Reset - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, }) .should('be.enabled') @@ -158,7 +158,7 @@ function saveButtonValidation() { SAMBA_DROPDOWN_VALUE ); // Confirm Save button is enabled once dropdown value is changed and then click on Save - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) diff --git a/cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js b/cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js index d7af1ff4e16..ba9de390693 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js @@ -92,7 +92,7 @@ function selectConfigMenu(menuOption) { function addSchedule() { selectConfigMenu(ADD_SCHEDULE_CONFIG_OPTION); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }).should('be.disabled'); @@ -126,7 +126,7 @@ function addSchedule() { urlPattern: '/ops/schedule_edit/new?button=save', triggerFn: () => cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) @@ -432,20 +432,20 @@ describe('Automate Schedule form operations: Settings > Application Settings > S cy.getFormInputFieldByIdAndType({ inputId: 'start_time' }) .should('be.visible') .and('be.enabled'); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) .should('be.visible') .and('be.disabled'); - cy.getFormFooterButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) .should('be.visible') .and('be.enabled'); }); it('Checking whether Cancel button works on the Add form', () => { selectConfigMenu(ADD_SCHEDULE_CONFIG_OPTION); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_OPERATION_CANCELED); @@ -465,7 +465,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S cy.getFormInputFieldByIdAndType({ inputId: 'description' }) .clear() .type(EDITED_DESCRIPTION); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) @@ -490,7 +490,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S cy.getFormInputFieldByIdAndType({ inputId: 'start_date' }) .clear() .type(EDITED_START_DATE); - cy.getFormFooterButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) .should('be.enabled') .click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_RESET_SCHEDULE); @@ -504,7 +504,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S ); /* ===== Checking whether Cancel button works ===== */ - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.success, FLASH_MESSAGE_OPERATION_CANCELED); diff --git a/cypress/e2e/ui/Settings/Application-Settings/settings_access_control.cy.js b/cypress/e2e/ui/Settings/Application-Settings/settings_access_control.cy.js index 2ef62ed3538..a85c276b9f4 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/settings_access_control.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/settings_access_control.cy.js @@ -37,7 +37,7 @@ describe('Settings > Application Settings > Access Control', () => { cy.getFormInputFieldByIdAndType({ inputId: 'description' }).type( INITIAL_TENANT_DESCRIPTION ); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: 'Add', buttonType: 'submit', }).click(); diff --git a/cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js b/cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js index ecf15be755b..cd2727b0b25 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/tenant.cy.js @@ -69,7 +69,7 @@ function confirmUiNavigation(callback) { } function cancelFormWithOptionalFlashCheck(assertFlashMessage = true) { - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); if (assertFlashMessage) { @@ -78,7 +78,7 @@ function cancelFormWithOptionalFlashCheck(assertFlashMessage = true) { } function resetFormAndAssertFlashMessage(buttonType = 'reset') { - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, buttonType, }) @@ -101,7 +101,7 @@ function saveFormWithOptionalFlashCheck({ urlPattern: /\/api\/tenants.*/, triggerFn: () => cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText: button, buttonType: 'submit', }) @@ -145,15 +145,15 @@ function validateFormElements(isEditForm = true) { cy.getFormInputFieldByIdAndType({ inputId: 'description' }) .should('be.visible') .and('be.enabled'); - cy.getFormFooterButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT }) .should('be.visible') .and('be.enabled'); if (isEditForm) { - cy.getFormFooterButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) .should('be.visible') .and('be.disabled'); } - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: isEditForm ? SAVE_BUTTON_TEXT : ADD_BUTTON_TEXT, buttonType: 'submit', }) @@ -328,7 +328,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc }); it('Validate Reset & Cancel buttons in Manage Quotas form', () => { - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, buttonType: 'reset', }).should('be.disabled'); @@ -466,7 +466,7 @@ describe('Automate Tenant form operations: Settings > Application Settings > Acc }); it('Validate Reset & Cancel buttons in Manage Quotas form', () => { - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT, buttonType: 'reset', }).should('be.disabled'); diff --git a/cypress/e2e/ui/Settings/Application-Settings/zone.cy.js b/cypress/e2e/ui/Settings/Application-Settings/zone.cy.js index 59e1dc64101..bf733a8ec24 100644 --- a/cypress/e2e/ui/Settings/Application-Settings/zone.cy.js +++ b/cypress/e2e/ui/Settings/Application-Settings/zone.cy.js @@ -69,7 +69,7 @@ function addZone() { urlPattern: '/api/zones', triggerFn: () => cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText: ADD_BUTTON_TEXT, buttonType: 'submit', }) @@ -124,7 +124,7 @@ function validateFormElements(isEditForm = false) { }, ]); // Validate form footer buttons - cy.validateFormFooterButtons([ + cy.validateFormButtons([ { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: CANCEL_BUTTON_TEXT, }, @@ -186,7 +186,7 @@ describe('Automate Zone form operations: Settings > Application Settings > Setti it('Checking whether cancel button works on the add form', () => { cy.toolbar(CONFIG_TOOLBAR_BUTTON, ADD_ZONE_CONFIG_OPTION); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_OPERATION_CANCELED); @@ -208,7 +208,7 @@ describe('Automate Zone form operations: Settings > Application Settings > Setti cy.getFormSelectFieldById({ selectId: 'settings.concurrent_vm_scans', }).select(UPDATED_MAX_SCAN_LIMIT); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: SAVE_BUTTON_TEXT, buttonType: 'submit', }) @@ -232,7 +232,7 @@ describe('Automate Zone form operations: Settings > Application Settings > Setti }); cy.toolbar(CONFIG_TOOLBAR_BUTTON, EDIT_ZONE_CONFIG_OPTION); validateFormElements(true); - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); }); @@ -251,7 +251,7 @@ describe('Automate Zone form operations: Settings > Application Settings > Setti cy.getFormInputFieldByIdAndType({ inputId: 'settings.proxy_server_ip' }) .clear() .type(UPDATED_SERVER_IP); - cy.getFormFooterButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) + cy.getFormButtonByTypeWithText({ buttonText: RESET_BUTTON_TEXT }) .should('be.enabled') .click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_OPERATION_RESET); @@ -263,7 +263,7 @@ describe('Automate Zone form operations: Settings > Application Settings > Setti inputId: 'settings.proxy_server_ip', }).should('have.value', INITIAL_SERVER_IP); /* ===== Cancel ===== */ - cy.getFormFooterButtonByTypeWithText({ + cy.getFormButtonByTypeWithText({ buttonText: CANCEL_BUTTON_TEXT, }).click(); cy.expect_flash(flashClassMap.warning, FLASH_MESSAGE_OPERATION_CANCELED); diff --git a/cypress/support/commands/constants/command_constants.js b/cypress/support/commands/constants/command_constants.js index c535d81f32c..69e45811b77 100644 --- a/cypress/support/commands/constants/command_constants.js +++ b/cypress/support/commands/constants/command_constants.js @@ -31,7 +31,6 @@ export const BUTTON_CONFIG_KEYS = { BUTTON_TEXT: 'buttonText', BUTTON_TYPE: 'buttonType', SHOULD_BE_DISABLED: 'shouldBeDisabled', - BUTTON_WRAPPER_CLASS: 'buttonWrapperClass', }; /* ========================================================== */ diff --git a/cypress/support/commands/element_selectors.js b/cypress/support/commands/element_selectors.js index 2854d64086e..c8422e0cffa 100644 --- a/cypress/support/commands/element_selectors.js +++ b/cypress/support/commands/element_selectors.js @@ -4,23 +4,21 @@ * @param {Object} options - The options object. * @param {string} options.buttonText - The text content of the button (required). * @param {string} [options.buttonType='button'] - The HTML button type (e.g., 'button', 'submit', 'reset'). Defaults to 'button'. - * @param {string} [options.buttonWrapperClass='bx--btn-set'] - The CSS class of the wrapper element containing the buttons. Defaults to 'bx--btn-set'. * @returns {Element} The matched button element. * @throws {Error} If buttonText is not provided. * * Example: - * cy.getFormFooterButtonByTypeWithText({ buttonText: 'Save Changes' }); - * cy.getFormFooterButtonByTypeWithText({ buttonText: 'Submit', buttonType: 'submit' }); - * cy.getFormFooterButtonByTypeWithText({ buttonText: 'Cancel', buttonWrapperClass: 'custom-wrapper' }); + * cy.getFormButtonByTypeWithText({ buttonText: 'Save Changes' }); + * cy.getFormButtonByTypeWithText({ buttonText: 'Submit', buttonType: 'submit' }); */ Cypress.Commands.add( - 'getFormFooterButtonByTypeWithText', - ({ buttonType = 'button', buttonText, buttonWrapperClass = 'bx--btn-set' } = {}) => { + 'getFormButtonByTypeWithText', + ({ buttonType = 'button', buttonText } = {}) => { if (!buttonText) { cy.logAndThrowError('buttonText is required'); } return cy.contains( - `#main-content .${buttonWrapperClass} button[type="${buttonType}"]`, + `#main-content button[type="${buttonType}"]`, buttonText ); } diff --git a/cypress/support/commands/form_elements_validation_commands.js b/cypress/support/commands/form_elements_validation_commands.js index f1f1ab0ad10..b080e48ac24 100644 --- a/cypress/support/commands/form_elements_validation_commands.js +++ b/cypress/support/commands/form_elements_validation_commands.js @@ -208,10 +208,9 @@ Cypress.Commands.add('validateFormFields', (fieldConfigs) => { * @param {string} buttonConfigs[].buttonText - The text of the button * @param {string} [buttonConfigs[].buttonType='button'] - The type of button (e.g., 'submit', 'reset') * @param {boolean} [buttonConfigs[].shouldBeDisabled=false] - Whether the button should be disabled - * @param {string} [buttonConfigs[].buttonWrapperClass='bx--btn-set'] - The CSS class of the wrapper element containing the buttons * * Example: - * cy.validateFormFooterButtons([ + * cy.validateFormButtons([ * { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Cancel' }, * { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Reset', [BUTTON_CONFIG_KEYS.SHOULD_BE_DISABLED]: true }, * { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Submit', [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit' }, @@ -219,16 +218,15 @@ Cypress.Commands.add('validateFormFields', (fieldConfigs) => { * ]); * * Or using regular object keys: - * cy.validateFormFooterButtons([ + * cy.validateFormButtons([ * { buttonText: 'Cancel' }, * { buttonText: 'Reset', shouldBeDisabled: true }, * { buttonText: 'Submit', buttonType: 'submit' }, - * { buttonText: 'Save', buttonWrapperClass: 'custom-wrapper' } * ]); * * Both approaches work but using config-keys object(BUTTON_CONFIG_KEYS) is recommended to avoid typos and unknown keys */ -Cypress.Commands.add('validateFormFooterButtons', (buttonConfigs) => { +Cypress.Commands.add('validateFormButtons', (buttonConfigs) => { if (!Array.isArray(buttonConfigs)) { cy.logAndThrowError('buttonConfigs must be an array'); } @@ -244,7 +242,6 @@ Cypress.Commands.add('validateFormFooterButtons', (buttonConfigs) => { const buttonType = config[BUTTON_CONFIG_KEYS.BUTTON_TYPE] || 'button'; const shouldBeDisabled = config[BUTTON_CONFIG_KEYS.SHOULD_BE_DISABLED] || false; - const buttonWrapperClass = config[BUTTON_CONFIG_KEYS.BUTTON_WRAPPER_CLASS]; if (!buttonText) { cy.logAndThrowError( @@ -253,10 +250,9 @@ Cypress.Commands.add('validateFormFooterButtons', (buttonConfigs) => { } const buttonCheck = cy - .getFormFooterButtonByTypeWithText({ + .getFormButtonByTypeWithText({ buttonText, buttonType, - buttonWrapperClass, }) .should('be.visible');