Skip to content

Commit 8cc33a7

Browse files
C&U gap collection form elements validation via commands
1 parent ace2745 commit 8cc33a7

File tree

1 file changed

+41
-28
lines changed

1 file changed

+41
-28
lines changed

cypress/e2e/ui/Settings/Application-Settings/c_and_u_gap_collection.cy.js

Lines changed: 41 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
/* eslint-disable no-undef */
2+
// TODO: Use aliased import(@cypress-dir) once #9631 is merged
23
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';
39

410
// Menu options
511
const SETTINGS_MENU_OPTION = 'Settings';
@@ -74,34 +80,41 @@ describe('Automate C & U Gap Collection form operations: Settings > Application
7480
cy.contains('#main-content .bx--form h3', FORM_SUBHEADER_SNIPPET).should(
7581
'be.visible'
7682
);
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+
]);
105118
});
106119

107120
it('Should fail if start date is greater than end date', () => {

0 commit comments

Comments
 (0)