Skip to content

Commit aec6b4f

Browse files
Update form button validation command to accept wrapper-class argument
1 parent 54ec61b commit aec6b4f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cypress/support/commands/constants/command_constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export const BUTTON_CONFIG_KEYS = {
3030
BUTTON_TEXT: 'buttonText',
3131
BUTTON_TYPE: 'buttonType',
3232
SHOULD_BE_DISABLED: 'shouldBeDisabled',
33+
BUTTON_WRAPPER_CLASS: 'buttonWrapperClass',
3334
};
3435

3536
/* ========================================================== */

cypress/support/commands/form_elements_validation_commands.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,19 +198,22 @@ Cypress.Commands.add('validateFormFields', (fieldConfigs) => {
198198
* @param {string} buttonConfigs[].buttonText - The text of the button
199199
* @param {string} [buttonConfigs[].buttonType='button'] - The type of button (e.g., 'submit', 'reset')
200200
* @param {boolean} [buttonConfigs[].shouldBeDisabled=false] - Whether the button should be disabled
201+
* @param {string} [buttonConfigs[].buttonWrapperClass='bx--btn-set'] - The CSS class of the wrapper element containing the buttons
201202
*
202203
* Example:
203204
* cy.validateFormFooterButtons([
204205
* { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Cancel' },
205206
* { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Reset', [BUTTON_CONFIG_KEYS.SHOULD_BE_DISABLED]: true },
206-
* { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Submit', [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit' }
207+
* { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Submit', [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit' },
208+
* { [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Save', [BUTTON_CONFIG_KEYS.BUTTON_WRAPPER_CLASS]: 'custom-wrapper' }
207209
* ]);
208210
*
209211
* Or using regular object keys:
210212
* cy.validateFormFooterButtons([
211213
* { buttonText: 'Cancel' },
212214
* { buttonText: 'Reset', shouldBeDisabled: true },
213-
* { buttonText: 'Submit', buttonType: 'submit' }
215+
* { buttonText: 'Submit', buttonType: 'submit' },
216+
* { buttonText: 'Save', buttonWrapperClass: 'custom-wrapper' }
214217
* ]);
215218
*
216219
* Both approaches work but using config-keys object(BUTTON_CONFIG_KEYS) is recommended to avoid typos and unknown keys
@@ -231,6 +234,7 @@ Cypress.Commands.add('validateFormFooterButtons', (buttonConfigs) => {
231234
const buttonType = config[BUTTON_CONFIG_KEYS.BUTTON_TYPE] || 'button';
232235
const shouldBeDisabled =
233236
config[BUTTON_CONFIG_KEYS.SHOULD_BE_DISABLED] || false;
237+
const buttonWrapperClass = config[BUTTON_CONFIG_KEYS.BUTTON_WRAPPER_CLASS];
234238

235239
if (!buttonText) {
236240
cy.logAndThrowError(
@@ -242,6 +246,7 @@ Cypress.Commands.add('validateFormFooterButtons', (buttonConfigs) => {
242246
.getFormFooterButtonByTypeWithText({
243247
buttonText,
244248
buttonType,
249+
buttonWrapperClass,
245250
})
246251
.should('be.visible');
247252

0 commit comments

Comments
 (0)