Skip to content

Commit aff03dc

Browse files
Added detailed component tests
1 parent f4913f3 commit aff03dc

File tree

1 file changed

+40
-8
lines changed

1 file changed

+40
-8
lines changed

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

Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const textConstants = {
1212
zoneAccordItem: /^Zone:/,
1313
serverAccordItem: /^Server:/,
1414

15+
// Field values
16+
formHeader: 'Editing Log Depot settings',
17+
formSubheaderSnippet: 'Editing Log Depot Settings',
18+
1519
// Config options
1620
editToolbarButton: 'Edit',
1721

@@ -61,6 +65,8 @@ const {
6165
flashMessageOperationCanceled,
6266
submitButtonType,
6367
protocolSelectFieldId,
68+
formHeader,
69+
formSubheaderSnippet,
6470
} = textConstants;
6571

6672
function interceptAndAwaitApi({
@@ -146,17 +152,39 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) {
146152
});
147153
}
148154

155+
function validateFormElements() {
156+
// Assert form header is visible
157+
cy.expect_explorer_title(formHeader).should('be.visible');
158+
// Assert form sub-header is visible
159+
cy.contains('#main-content .bx--form h3', formSubheaderSnippet).should(
160+
'be.visible'
161+
);
162+
// Assert protocol field label is visible
163+
cy.getFormLabelByInputId(protocolSelectFieldId).should('be.visible');
164+
// Assert protocol field is visible and enabled
165+
cy.getFormSelectFieldById(protocolSelectFieldId).should('be.visible');
166+
// Assert cancel button is visible and enabled
167+
cy.getFormFooterButtonByType(cancelButton)
168+
.should('be.visible')
169+
.and('be.enabled');
170+
// Assert save button is visible and disabled
171+
cy.getFormFooterButtonByType(saveButton, submitButtonType)
172+
.should('be.visible')
173+
.and('be.disabled');
174+
// Assert reset button is visible and disabled
175+
cy.getFormFooterButtonByType(resetButton)
176+
.should('be.visible')
177+
.and('be.disabled');
178+
}
179+
149180
function cancelButtonValidation() {
150181
// Click cancel button in the form
151-
cy.getFormFooterButtonByType(cancelButton).should('be.enabled').click();
182+
cy.getFormFooterButtonByType(cancelButton).click();
152183
// Validating confirmation flash message
153184
cy.expect_flash(flashTypeSuccess, flashMessageOperationCanceled);
154185
}
155186

156187
function resetButtonValidation() {
157-
// Confirm Reset button is disabled initially
158-
cy.getFormFooterButtonByType(resetButton).should('be.disabled');
159-
160188
// Selecting Samba option from dropdown
161189
cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue);
162190
// Confirm Reset button is enabled once dropdown value is changed and then click on Reset
@@ -169,10 +197,6 @@ function resetButtonValidation() {
169197
}
170198

171199
function saveButtonValidation() {
172-
// Confirm Save button is disabled initially
173-
cy.getFormFooterButtonByType(saveButton, submitButtonType).should(
174-
'be.disabled'
175-
);
176200
// Selecting Samba option from dropdown
177201
cy.getFormSelectFieldById(protocolSelectFieldId).select(sambaDropdownValue);
178202
// Confirm Save button is enabled once dropdown value is changed and then click on Save
@@ -214,6 +238,10 @@ describe('Automate Collect logs Edit form operations', () => {
214238
goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts);
215239
});
216240

241+
it('Validate form elements', () => {
242+
validateFormElements();
243+
});
244+
217245
it('Validate Cancel button', () => {
218246
cancelButtonValidation();
219247
});
@@ -258,6 +286,10 @@ describe('Automate Collect logs Edit form operations', () => {
258286
goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts);
259287
});
260288

289+
it('Validate form elements', () => {
290+
validateFormElements();
291+
});
292+
261293
it('Validate Cancel button', () => {
262294
cancelButtonValidation();
263295
});

0 commit comments

Comments
 (0)