@@ -47,6 +47,25 @@ const textConstants = {
4747 // Menu options
4848 settingsMenuOption : 'Settings' ,
4949 appSettingsMenuOption : 'Application Settings' ,
50+
51+ // Flash message types
52+ flashTypeSuccess : 'success' ,
53+ flashTypeWarning : 'warning' ,
54+ flashTypeError : 'error' ,
55+ flashTypeInfo : 'info' ,
56+
57+ // Flash message text snippets
58+ flashMessageScheduleQueued : 'queued to run' ,
59+ flashMessageOperationCanceled : 'cancelled' ,
60+ flashMessageScheduleDisabled : 'disabled' ,
61+ flashMessageScheduleEnabled : 'enabled' ,
62+ flashMessageScheduleSaved : 'saved' ,
63+ flashMessageResetSchedule : 'reset' ,
64+ flashMessageScheduleDeleted : 'delete successful' ,
65+ flashMessageFailedToAddSchedule : 'failed' ,
66+
67+ // Browser alert text snippets
68+ browserAlertDeleteConfirmText : 'will be permanently removed' ,
5069} ;
5170
5271const {
@@ -86,6 +105,19 @@ const {
86105 startTime,
87106 deleteScheduleConfigOption,
88107 schedulesAccordionItem,
108+ flashTypeSuccess,
109+ flashTypeWarning,
110+ flashTypeError,
111+ flashTypeInfo,
112+ flashMessageScheduleQueued,
113+ flashMessageOperationCanceled,
114+ flashMessageScheduleDisabled,
115+ flashMessageScheduleEnabled,
116+ flashMessageScheduleSaved,
117+ flashMessageResetSchedule,
118+ flashMessageScheduleDeleted,
119+ flashMessageFailedToAddSchedule,
120+ browserAlertDeleteConfirmText,
89121} = textConstants ;
90122
91123function selectConfigMenu ( configuration = addScheduleConfigOption ) {
@@ -137,8 +169,9 @@ function deleteSchedule(scheduleName = initialScheduleName) {
137169 // Listening for the browser confirm alert and confirming deletion
138170 cy . expect_browser_confirm_with_text ( {
139171 confirmTriggerFn : ( ) => selectConfigMenu ( deleteScheduleConfigOption ) ,
172+ containsText : browserAlertDeleteConfirmText ,
140173 } ) ;
141- cy . expect_flash ( 'success' ) ;
174+ cy . expect_flash ( flashTypeSuccess , flashMessageScheduleDeleted ) ;
142175}
143176
144177function invokeCleanupDeletion ( ) {
@@ -323,13 +356,13 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
323356 )
324357 . should ( 'be.enabled' )
325358 . click ( ) ;
326- cy . expect_flash ( 'success' ) ;
359+ cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
327360 } ) ;
328361
329362 it ( 'Checking whether add, edit & delete schedule works' , ( ) => {
330363 /* ===== Adding a schedule ===== */
331364 addSchedule ( ) ;
332- cy . expect_flash ( 'success' ) ;
365+ cy . expect_flash ( flashTypeSuccess , flashMessageScheduleSaved ) ;
333366
334367 /* ===== Editing a schedule ===== */
335368 // Selecting the created schedule
@@ -342,7 +375,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
342375 cy . contains ( '#main-content .bx--btn-set button[type="submit"]' , saveButton )
343376 . should ( 'be.enabled' )
344377 . click ( ) ;
345- cy . expect_flash ( 'success' ) ;
378+ cy . expect_flash ( flashTypeSuccess , flashMessageScheduleSaved ) ;
346379
347380 /* ===== Delete is already handled from afterEach hook ===== */
348381 } ) ;
@@ -361,7 +394,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
361394 )
362395 . should ( 'be.enabled' )
363396 . click ( ) ;
364- cy . expect_flash ( 'success' ) ;
397+ cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
365398
366399 /* ===== Checking whether Reset button works ===== */
367400 // Selecting the created schedule
@@ -373,7 +406,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
373406 cy . contains ( '#main-content .bx--btn-set button[type="button"]' , resetButton )
374407 . should ( 'be.enabled' )
375408 . click ( ) ;
376- cy . expect_flash ( 'warning' ) ;
409+ cy . expect_flash ( flashTypeWarning , flashMessageResetSchedule ) ;
377410 // Confirming the edited fields contain the old values after resetting
378411 cy . get ( 'input#description' ) . should ( 'have.value' , initialDescription ) ;
379412 cy . get ( 'input#start_date' ) . should ( 'have.value' , initialStartDate ) ;
@@ -388,7 +421,7 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
388421
389422 /* ===== Trying to add the same schedule again ===== */
390423 addSchedule ( ) ;
391- cy . expect_flash ( 'error' ) ;
424+ cy . expect_flash ( flashTypeError , flashMessageFailedToAddSchedule ) ;
392425 } ) ;
393426
394427 it ( 'Checking whether Disabling, Enabling & Queueing up the schedule works' , ( ) => {
@@ -399,15 +432,15 @@ describe('Automate Schedule form operations: Settings > Application Settings > S
399432
400433 /* ===== Disabling the schedule ===== */
401434 selectConfigMenu ( disableScheduleConfigOption ) ;
402- cy . expect_flash ( 'info' ) ;
435+ cy . expect_flash ( flashTypeInfo , flashMessageScheduleDisabled ) ;
403436
404437 /* ===== Enabling the schedule ===== */
405438 selectConfigMenu ( enableScheduleConfigOption ) ;
406- cy . expect_flash ( 'info' ) ;
439+ cy . expect_flash ( flashTypeInfo , flashMessageScheduleEnabled ) ;
407440
408441 /* ===== Queueing-up the schedule ===== */
409442 selectConfigMenu ( queueScheduleConfigOption ) ;
410- cy . expect_flash ( 'success' ) ;
443+ cy . expect_flash ( flashTypeSuccess , flashMessageScheduleQueued ) ;
411444 } ) ;
412445
413446 afterEach ( ( ) => {
0 commit comments