Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cypress/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'});`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

according to #9689 we wanted to generalize this to be form buttons not just in footers... maybe:

retrieves a form button, often found in form footers, by its name and type

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it makes sense, let's fix this in a followup.

* `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'});`
Expand All @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
})
Expand Down Expand Up @@ -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');
}
Expand Down Expand Up @@ -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);
Expand All @@ -159,15 +159,15 @@ 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();
});

it('Validate Edit Namespace form fields', () => {
createNamespaceAndOpenEditForm();
validateNamespaceFormFields(true);
cy.getFormFooterButtonByTypeWithText({
cy.getFormButtonByTypeWithText({
buttonText: CANCEL_BUTTON_TEXT,
}).click();
});
Expand All @@ -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',
})
Expand All @@ -211,15 +211,15 @@ 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();
});

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' })
Expand All @@ -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);
Expand All @@ -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);
Expand Down
14 changes: 7 additions & 7 deletions cypress/e2e/ui/Services/Catalogs/catalog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ function validateElements({ isEditForm }) {
},
]);
// Validate form footer buttons
cy.validateFormFooterButtons([
cy.validateFormButtons([
{
[BUTTON_CONFIG_KEYS.BUTTON_TEXT]: isEditForm
? SAVE_BUTTON_TEXT
Expand Down Expand Up @@ -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);
Expand All @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions cypress/e2e/ui/Services/Catalogs/copy_catalog.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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);
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function saveFormAndAssertFlashMessage(flashMessageType, flashMessage) {
urlPattern: '/ops/cu_repair?button=submit',
triggerFn: () =>
cy
.getFormFooterButtonByTypeWithText({
.getFormButtonByTypeWithText({
buttonText: 'Save',
buttonType: 'submit',
})
Expand Down Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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')
Expand All @@ -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
Expand All @@ -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')
Expand All @@ -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',
})
Expand Down
16 changes: 8 additions & 8 deletions cypress/e2e/ui/Settings/Application-Settings/schedule.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -126,7 +126,7 @@ function addSchedule() {
urlPattern: '/ops/schedule_edit/new?button=save',
triggerFn: () =>
cy
.getFormFooterButtonByTypeWithText({
.getFormButtonByTypeWithText({
buttonText: SAVE_BUTTON_TEXT,
buttonType: 'submit',
})
Expand Down Expand Up @@ -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);
Expand All @@ -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',
})
Expand All @@ -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);
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading