Skip to content

Commit 298f77f

Browse files
committed
Updates cy test
1 parent 22b3872 commit 298f77f

File tree

1 file changed

+206
-0
lines changed
  • cypress/e2e/ui/Automation/Embedded-Automate/customization/service-dialogs

1 file changed

+206
-0
lines changed
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
describe('Service Dialog Edit', () => {
2+
// Reusable function to create a service dialog with fields
3+
const createServiceDialog = (dialogName) => {
4+
cy.navigateToAddDialog();
5+
cy.get('#dialogName').type(dialogName);
6+
cy.get('#dialogDescription').type('Dialog description');
7+
cy.dragAndDropComponent('Text Box');
8+
cy.openFieldEditModal(0, 0, 0);
9+
10+
// Set values in Field Information tab
11+
cy.get('.edit-field-modal input[name="label"]')
12+
.clear()
13+
.type('Text Field');
14+
15+
// Switch to Options tab
16+
cy.get('.edit-field-modal .edit-field-modal-body ul[role=tablist] li')
17+
.eq(1)
18+
.click();
19+
cy.get('.edit-field-modal input[name="value"]')
20+
.clear()
21+
.type('Initial Value');
22+
23+
// Save the changes
24+
cy.get('.edit-field-modal button[type="submit"]')
25+
.click();
26+
27+
// Add a checkbox field
28+
cy.dragAndDropComponent('Check Box');
29+
cy.openFieldEditModal(0, 0, 1);
30+
// Set a value in the Field Information tab
31+
cy.get('.edit-field-modal input[name="label"]')
32+
.clear()
33+
.type('Custom Label');
34+
35+
// Switch to Options tab
36+
cy.get('.edit-field-modal .edit-field-modal-body ul[role=tablist] li')
37+
.eq(1)
38+
.click();
39+
40+
// Set a value in the Options tab
41+
cy.get('.edit-field-modal label[for="checked"]').click();
42+
43+
// Save the changes
44+
cy.get('.edit-field-modal button[type="submit"]')
45+
.click();
46+
47+
// Step 10: Save the dialog
48+
cy.get('.service-dialog-main-wrapper .custom-button-wrapper button').contains('Submit').click();
49+
50+
// Verify we're back at the explorer page and the dialog was created
51+
cy.url().should('include', '/miq_ae_customization/explorer');
52+
53+
// Use selectAccordionItem to navigate to All Dialogs
54+
cy.selectAccordionItem([
55+
/^All Dialogs/,
56+
dialogName,
57+
]);
58+
59+
return dialogName;
60+
};
61+
62+
// Clean up dialogs created during tests
63+
const deleteDialog = (dialogName) => {
64+
cy.selectAccordionItem([
65+
/^All Dialogs/,
66+
dialogName,
67+
]);
68+
69+
cy.expect_browser_confirm_with_text({
70+
containsText: 'Warning: This Dialog will be permanently removed!',
71+
proceed: true,
72+
confirmTriggerFn: () => {
73+
return cy.toolbar('Configuration', 'Remove Dialog');
74+
},
75+
});
76+
77+
// Verify the dialog was deleted
78+
cy.get('.flash_text_div .alert-success')
79+
.should('contain', 'Dialog "Test Dialog": Delete successful');
80+
};
81+
82+
beforeEach(() => {
83+
cy.login();
84+
});
85+
86+
// Clean up after each test
87+
afterEach(function() {
88+
deleteDialog('Test Dialog');
89+
});
90+
91+
it('should create a service dialog with fields and verify edit functionality', function() {
92+
// Create a unique dialog name
93+
const dialogName = 'Test Dialog';
94+
95+
// Create the service dialog
96+
createServiceDialog(dialogName);
97+
98+
// Navigate to edit the dialog
99+
cy.toolbar('Configuration', 'Edit this Dialog');
100+
101+
// Verify field values are displayed correctly
102+
cy.get('.dynamic-form-field').contains('Text Field').parent().find('input').should('have.value', 'Initial Value');
103+
cy.get('.dynamic-form-field').contains('Custom Label').parent().find('input[type="checkbox"]').should('be.checked');
104+
105+
// Make changes to the fields
106+
cy.openFieldEditModal(0, 0, 0);
107+
108+
// Switch to Options tab
109+
cy.get('.edit-field-modal .edit-field-modal-body ul[role=tablist] li')
110+
.eq(1)
111+
.click();
112+
cy.get('.edit-field-modal input[name="value"]').clear().type('Updated Value');
113+
cy.get('.edit-field-modal button[type="submit"]').click();
114+
115+
cy.openFieldEditModal(0, 0, 1);
116+
117+
// Switch to Options tab
118+
cy.get('.edit-field-modal .edit-field-modal-body ul[role=tablist] li')
119+
.eq(1)
120+
.click();
121+
cy.get('.edit-field-modal label[for="checked"]').click();
122+
cy.get('.edit-field-modal button[type="submit"]').click();
123+
124+
// Submit the form to save changes
125+
cy.get('button[type="submit"]').contains('Submit').click();
126+
127+
// Verify we're back at the explorer page
128+
cy.url().should('include', '/miq_ae_customization/explorer');
129+
130+
// Navigate back to edit to verify persistence
131+
cy.toolbar('Configuration', 'Edit this Dialog');
132+
133+
// Verify updated values
134+
cy.get('.dynamic-form-field').contains('Text Field').parent().find('input').should('have.value', 'Updated Value');
135+
cy.get('.dynamic-form-field').contains('Custom Label').parent().find('input[type="checkbox"]').should('not.be.checked');
136+
137+
cy.get('button[type="button"]').contains('Cancel').click();
138+
});
139+
140+
it.only('should navigate back to explorer when Cancel button is clicked', function() {
141+
// Create a unique dialog name
142+
const dialogName = `Cancel Test Dialog ${Date.now()}`;
143+
this.currentTest.dialogName = dialogName;
144+
145+
// Create the service dialog
146+
createServiceDialog(dialogName);
147+
148+
// Navigate to edit page for the dialog
149+
cy.get('.miq-data-table').contains(dialogName).click();
150+
cy.get('#center_tb').contains('Configuration').click();
151+
cy.get('ul.dropdown-menu').contains('Edit this Dialog').click();
152+
153+
// Make a change that shouldn't be saved
154+
cy.get('#dialogName').clear().type(`${dialogName} - Modified`);
155+
156+
// Click Cancel button
157+
cy.get('button').contains('Cancel').click();
158+
159+
// Verify we're back at the explorer page
160+
cy.url().should('include', '/miq_ae_customization/explorer');
161+
162+
// Verify the dialog name wasn't changed
163+
cy.get('#search_text').clear().type(dialogName);
164+
cy.get('#searchicon').click();
165+
cy.get('.miq-data-table').contains(dialogName).should('be.visible');
166+
167+
cy.get('#search_text').clear().type(`${dialogName} - Modified`);
168+
cy.get('#searchicon').click();
169+
cy.get('.miq-data-table').should('not.contain', `${dialogName} - Modified`);
170+
});
171+
172+
it('should update dialog name and navigate back when Submit button is clicked', function() {
173+
// Create a unique dialog name
174+
const dialogName = `Submit Test Dialog ${Date.now()}`;
175+
const updatedName = `Updated Dialog ${Date.now()}`;
176+
this.currentTest.dialogName = updatedName; // Use the updated name for cleanup
177+
178+
// Create the service dialog
179+
createServiceDialog(dialogName);
180+
181+
// Navigate to edit page for the dialog
182+
cy.get('.miq-data-table').contains(dialogName).click();
183+
cy.get('#center_tb').contains('Configuration').click();
184+
cy.get('ul.dropdown-menu').contains('Edit this Dialog').click();
185+
186+
// Make a change to the dialog name
187+
cy.get('#dialogName').clear().type(updatedName);
188+
189+
// Submit the form
190+
cy.get('button[type="submit"]').contains('Submit').click();
191+
192+
// Verify we're back at the explorer page
193+
cy.url().should('include', '/miq_ae_customization/explorer');
194+
195+
// Verify the dialog was updated
196+
cy.get('#search_text').clear().type(updatedName);
197+
cy.get('#searchicon').click();
198+
cy.get('.miq-data-table').contains(updatedName).should('be.visible');
199+
200+
cy.get('#search_text').clear().type(dialogName);
201+
cy.get('#searchicon').click();
202+
cy.get('.miq-data-table').should('not.contain', dialogName);
203+
});
204+
});
205+
206+
// Made with Bob

0 commit comments

Comments
 (0)