77 BUTTON_CONFIG_KEYS ,
88} from '../../../../support/commands/constants/command_constants' ;
99
10- // Component route url
11- const COMPONENT_ROUTE_URL = '/miq_request/show_list' ;
12-
1310// Menu options
1411const SERVICES_MENU_OPTION = 'Services' ;
1512const REQUESTS_MENU_OPTION = 'Requests' ;
@@ -30,8 +27,6 @@ const ALL_CATALOG_ITEMS_ACCORDION_ITEM = 'All Catalog Items';
3027const TOOLBAR_CONFIGURATION = 'Configuration' ;
3128const TOOLBAR_ADD_NEW_DIALOG = 'Add a new Dialog' ;
3229const TOOLBAR_ADD_CATALOG_ITEM = 'Add a New Catalog Item' ;
33- const TOOLBAR_REMOVE_SELECTED_DIALOGS = 'Remove selected Dialogs' ;
34- const TOOLBAR_DELETE_CATALOG_ITEMS = 'Delete Catalog Items' ;
3530
3631// Field labels
3732const FORM_HEADER = 'Requests' ;
@@ -60,14 +55,11 @@ const SAVE_BUTTON_TEXT = 'Save';
6055const ADD_BUTTON_TEXT = 'Add' ;
6156const ORDER_BUTTON_TEXT = 'Order' ;
6257const SUBMIT_BUTTON_TEXT = 'Submit' ;
63- const DELETE_BUTTON_TEXT = 'Delete' ;
6458
6559// Flash message text snippets
6660const FLASH_MESSAGE_ADD_SUCCESS = 'added' ;
6761const FLASH_MESSAGE_SAVE_SUCCESS = 'saved' ;
6862const FLASH_MESSAGE_SUBMITTED = 'submitted' ;
69- const ALERT_MESSAGE_DELETE = 'delete' ;
70- const BROWSER_CONFIRM_REMOVE_MESSAGE = 'remove' ;
7163
7264function dataSetup ( ) {
7365 // Adding a dialog
@@ -156,82 +148,6 @@ function dataSetup() {
156148 cy . expect_flash ( flashClassMap . success , FLASH_MESSAGE_SUBMITTED ) ;
157149}
158150
159- function cleanUp ( ) {
160- cy . url ( )
161- . then ( ( url ) => {
162- // Ensures navigation to Services -> Catalogs in the UI
163- if ( ! url . endsWith ( COMPONENT_ROUTE_URL ) ) {
164- cy . visit ( COMPONENT_ROUTE_URL ) ;
165- }
166- } )
167- . then ( ( ) => {
168- // Delete the request
169- // TODO: Replace with clickTableRowByText once #9691 is merged
170- cy . contains (
171- '.miq-data-table table tbody tr td' ,
172- CATALOG_ITEM_NAME
173- ) . click ( ) ;
174- // cy.clickTableRowByText({ text: CATALOG_ITEM_NAME, columnIndex: 6 });
175- cy . interceptApi ( {
176- urlPattern : / \/ m i q _ r e q u e s t \/ b u t t o n \/ \d + \? p r e s s e d = m i q _ r e q u e s t _ d e l e t e / ,
177- alias : 'deleteRequestApi' ,
178- triggerFn : ( ) =>
179- cy . expect_browser_confirm_with_text ( {
180- confirmTriggerFn : ( ) => cy . get ( 'button#miq_request_delete' ) . click ( ) ,
181- containsText : ALERT_MESSAGE_DELETE ,
182- } ) ,
183- onApiResponse : ( interception ) =>
184- expect ( interception . response . statusCode ) . to . equal ( 200 ) ,
185- } ) ;
186- // Delete catalog item
187- cy . menu ( SERVICES_MENU_OPTION , CATALOGS_MENU_OPTION ) ;
188- cy . accordion ( CATALOG_ITEMS_ACCORDION_ITEM ) ;
189- cy . selectAccordionItem ( [ ALL_CATALOG_ITEMS_ACCORDION_ITEM ] ) ;
190- cy . selectTableRowsByText ( {
191- textArray : [ CATALOG_ITEM_NAME ] ,
192- } ) ;
193- cy . toolbar ( TOOLBAR_CONFIGURATION , TOOLBAR_DELETE_CATALOG_ITEMS ) ;
194- cy . interceptApi ( {
195- urlPattern : / \/ a p i \/ s e r v i c e _ t e m p l a t e s \/ \d + $ / ,
196- alias : 'deleteCatalogItemApi' ,
197- triggerFn : ( ) =>
198- cy . expect_modal ( {
199- modalContentExpectedTexts : [ 'delete' , CATALOG_ITEM_NAME ] ,
200- targetFooterButtonText : DELETE_BUTTON_TEXT ,
201- } ) ,
202- onApiResponse : ( interception ) =>
203- expect ( interception . response . statusCode ) . to . equal ( 200 ) ,
204- } ) ;
205- // Delete service dialog
206- cy . menu (
207- AUTOMATION_MENU_OPTION ,
208- EMBEDDED_AUTOMATION_MENU_OPTION ,
209- CUSTOMIZATION_MENU_OPTION
210- ) ;
211- cy . accordion ( SERVICE_DIALOGS_ACCORDION ) ;
212- cy . selectAccordionItem ( [ ALL_DIALOGS_ACCORDION_ITEM ] ) ;
213- cy . selectTableRowsByText ( {
214- textArray : [ TEST_DIALOG_NAME ] ,
215- } ) ;
216- cy . interceptApi ( {
217- urlPattern : '/miq_ae_customization/x_button?pressed=dialog_delete' ,
218- alias : 'deleteDialogApi' ,
219- triggerFn : ( ) =>
220- cy . expect_browser_confirm_with_text ( {
221- confirmTriggerFn : ( ) =>
222- cy . toolbar (
223- TOOLBAR_CONFIGURATION ,
224- TOOLBAR_REMOVE_SELECTED_DIALOGS
225- ) ,
226- containsText : BROWSER_CONFIRM_REMOVE_MESSAGE ,
227- } ) ,
228- onApiResponse : ( interception ) =>
229- expect ( interception . response . statusCode ) . to . equal ( 200 ) ,
230- } ) ;
231- cy . expect_flash ( flashClassMap . success , ALERT_MESSAGE_DELETE ) ;
232- } ) ;
233- }
234-
235151describe ( 'Automate Service Requests form operations: Services > Requests' , ( ) => {
236152 beforeEach ( ( ) => {
237153 cy . login ( ) ;
@@ -512,8 +428,7 @@ describe('Automate Service Requests form operations: Services > Requests', () =>
512428 } ) ;
513429
514430 afterEach ( ( ) => {
515- // TODO: Replace with better cleanup approach
516- cleanUp ( ) ;
431+ cy . appDbState ( 'restore' ) ;
517432 } ) ;
518433 } ) ;
519434} ) ;
0 commit comments