Skip to content

Commit 712ba21

Browse files
authored
Merge pull request #9690 from asirvadAbrahamVarghese/enhance-element-validation-commands
Enhanced validateFormFields to assert checkbox state
2 parents f697e24 + 8933002 commit 712ba21

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

cypress/support/commands/constants/command_constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ export const FIELD_CONFIG_KEYS = {
1515
FIELD_TYPE: 'fieldType',
1616
INPUT_FIELD_TYPE: 'inputFieldType',
1717
SHOULD_BE_DISABLED: 'shouldBeDisabled',
18+
SHOULD_BE_CHECKED: 'shouldBeChecked',
1819
EXPECTED_VALUE: 'expectedValue',
1920
};
2021

cypress/support/commands/form_elements_validation_commands.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,16 @@ Cypress.Commands.add('validateFormFields', (fieldConfigs) => {
152152
if (expectedValue) {
153153
cy.wrap(field).should('have.value', expectedValue);
154154
}
155+
156+
if (inputFieldType === 'checkbox') {
157+
const shouldBeChecked =
158+
config[FIELD_CONFIG_KEYS.SHOULD_BE_CHECKED] || false;
159+
if (shouldBeChecked) {
160+
expect(field).to.be.checked;
161+
} else {
162+
expect(field).to.not.be.checked;
163+
}
164+
}
155165
});
156166
break;
157167
case FIELD_TYPES.SELECT:

0 commit comments

Comments
 (0)