1+ // eslint-disable-next-line no-undef
12describe ( 'Service Dialog Edit' , ( ) => {
23 // Reusable function to create a service dialog with fields
34 const createServiceDialog = ( dialogName ) => {
@@ -19,7 +20,7 @@ describe('Service Dialog Edit', () => {
1920 cy . get ( '.edit-field-modal input[name="value"]' )
2021 . clear ( )
2122 . type ( 'Initial Value' ) ;
22-
23+
2324 // Save the changes
2425 cy . get ( '.edit-field-modal button[type="submit"]' )
2526 . click ( ) ;
@@ -137,21 +138,23 @@ describe('Service Dialog Edit', () => {
137138 cy . get ( 'button[type="button"]' ) . contains ( 'Cancel' ) . click ( ) ;
138139 } ) ;
139140
140- it . only ( 'should navigate back to explorer when Cancel button is clicked' , function ( ) {
141+ it ( 'should navigate back to explorer when Cancel button is clicked' , function ( ) {
141142 // Create a unique dialog name
142- const dialogName = `Cancel Test Dialog ${ Date . now ( ) } ` ;
143- this . currentTest . dialogName = dialogName ;
143+ const dialogName = 'Test Dialog' ;
144144
145145 // Create the service dialog
146146 createServiceDialog ( dialogName ) ;
147147
148148 // 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 ( ) ;
149+ cy . toolbar ( 'Configuration' , 'Edit this Dialog' ) ;
152150
153151 // Make a change that shouldn't be saved
154- cy . get ( '#dialogName' ) . clear ( ) . type ( `${ dialogName } - Modified` ) ;
152+ cy . openFieldEditModal ( 0 , 0 , 0 ) ;
153+ cy . get ( '.edit-field-modal input[name="label"]' )
154+ . clear ( )
155+ . type ( 'Text Field Edited' ) ;
156+ cy . get ( '.edit-field-modal button[type="submit"]' )
157+ . click ( ) ;
155158
156159 // Click Cancel button
157160 cy . get ( 'button' ) . contains ( 'Cancel' ) . click ( ) ;
@@ -160,47 +163,12 @@ describe('Service Dialog Edit', () => {
160163 cy . url ( ) . should ( 'include' , '/miq_ae_customization/explorer' ) ;
161164
162165 // 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 ) ;
166+ cy . toolbar ( 'Configuration' , 'Edit this Dialog' ) ;
167+ cy . openFieldEditModal ( 0 , 0 , 0 ) ;
168+ cy . get ( '.edit-field-modal input[name="label"]' )
169+ . should ( 'not.contain' , 'Field Edited' ) ;
170+ cy . closeFieldEditModal ( ) ;
171+ cy . get ( 'button[type="button"]' ) . contains ( 'Cancel' ) . click ( ) ;
203172 } ) ;
204173} ) ;
205174
206- // Made with Bob
0 commit comments