|
1 | 1 | /* eslint-disable no-undef */
|
| 2 | +// TODO: Use aliased import(@cypress-dir) once #9631 is merged |
2 | 3 | import { flashClassMap } from '../../../../support/assertions/assertion_constants';
|
| 4 | +import { |
| 5 | + LABEL_CONFIG_KEYS, |
| 6 | + FIELD_CONFIG_KEYS, |
| 7 | + BUTTON_CONFIG_KEYS, |
| 8 | +} from '../../../../support/commands/command_constants'; |
3 | 9 |
|
4 | 10 | // Menu options
|
5 | 11 | const SETTINGS_MENU_OPTION = 'Settings';
|
@@ -74,34 +80,41 @@ describe('Automate C & U Gap Collection form operations: Settings > Application
|
74 | 80 | cy.contains('#main-content .bx--form h3', FORM_SUBHEADER_SNIPPET).should(
|
75 | 81 | 'be.visible'
|
76 | 82 | );
|
77 |
| - // Assert timezone label & field is visible and enabled |
78 |
| - cy.getFormLabelByForAttribute({ forValue: 'timezone' }) |
79 |
| - .should('be.visible') |
80 |
| - .and('contain.text', TIMEZONE_FIELD_LABEL); |
81 |
| - cy.getFormInputFieldByIdAndType({ inputId: 'timezone' }) |
82 |
| - .should('be.visible') |
83 |
| - .and('be.enabled'); |
84 |
| - // Assert start date label & field is visible and enabled |
85 |
| - cy.getFormLabelByForAttribute({ forValue: 'startDate' }) |
86 |
| - .should('be.visible') |
87 |
| - .and('contain.text', START_DATE_FIELD_LABEL); |
88 |
| - cy.getFormInputFieldByIdAndType({ inputId: 'startDate' }) |
89 |
| - .should('be.visible') |
90 |
| - .and('be.enabled'); |
91 |
| - // Assert end date label & field is visible and enabled |
92 |
| - cy.getFormLabelByForAttribute({ forValue: 'endDate' }) |
93 |
| - .should('be.visible') |
94 |
| - .and('contain.text', END_DATE_FIELD_LABEL); |
95 |
| - cy.getFormInputFieldByIdAndType({ inputId: 'endDate' }) |
96 |
| - .should('be.visible') |
97 |
| - .and('be.enabled'); |
98 |
| - // Assert save button is visible and disabled |
99 |
| - cy.getFormFooterButtonByTypeWithText({ |
100 |
| - buttonText: 'Save', |
101 |
| - buttonType: 'submit', |
102 |
| - }) |
103 |
| - .should('be.visible') |
104 |
| - .and('be.disabled'); |
| 83 | + |
| 84 | + // Validate form labels |
| 85 | + cy.validateFormLabels([ |
| 86 | + { |
| 87 | + [LABEL_CONFIG_KEYS.FOR_VALUE]: 'timezone', |
| 88 | + [LABEL_CONFIG_KEYS.EXPECTED_TEXT]: TIMEZONE_FIELD_LABEL, |
| 89 | + }, |
| 90 | + { |
| 91 | + [LABEL_CONFIG_KEYS.FOR_VALUE]: 'startDate', |
| 92 | + [LABEL_CONFIG_KEYS.EXPECTED_TEXT]: START_DATE_FIELD_LABEL, |
| 93 | + }, |
| 94 | + { |
| 95 | + [LABEL_CONFIG_KEYS.FOR_VALUE]: 'endDate', |
| 96 | + [LABEL_CONFIG_KEYS.EXPECTED_TEXT]: END_DATE_FIELD_LABEL, |
| 97 | + }, |
| 98 | + ]); |
| 99 | + |
| 100 | + // Validate form fields |
| 101 | + cy.validateFormFields([ |
| 102 | + { |
| 103 | + [FIELD_CONFIG_KEYS.ID]: 'timezone', |
| 104 | + [FIELD_CONFIG_KEYS.EXPECTED_VALUE]: '(GMT+00:00) UTC', |
| 105 | + }, |
| 106 | + { [FIELD_CONFIG_KEYS.ID]: 'startDate' }, |
| 107 | + { [FIELD_CONFIG_KEYS.ID]: 'endDate' }, |
| 108 | + ]); |
| 109 | + |
| 110 | + // Validate form footer buttons |
| 111 | + cy.validateFormFooterButtons([ |
| 112 | + { |
| 113 | + [BUTTON_CONFIG_KEYS.BUTTON_TEXT]: 'Save', |
| 114 | + [BUTTON_CONFIG_KEYS.BUTTON_TYPE]: 'submit', |
| 115 | + [BUTTON_CONFIG_KEYS.SHOULD_BE_DISABLED]: true, |
| 116 | + }, |
| 117 | + ]); |
105 | 118 | });
|
106 | 119 |
|
107 | 120 | it('Should fail if start date is greater than end date', () => {
|
|
0 commit comments