@@ -12,21 +12,23 @@ const textConstants = {
1212 zoneAccordItem : / ^ Z o n e : / ,
1313 serverAccordItem : / ^ S e r v e r : / ,
1414
15+ // Config options
16+ editToolbarButton : 'Edit' ,
17+
1518 // Buttons
1619 saveButton : 'Save' ,
1720 cancelButton : 'Cancel' ,
1821 resetButton : 'Reset' ,
1922
23+ // Common element IDs
24+ protocolSelectFieldId : 'log_protocol' ,
25+
2026 // Dropdown values
2127 dropdownBlankValue : 'BLANK_VALUE' ,
2228 sambaDropdownValue : 'FileDepotSmb' ,
2329
24- // Common selectors
25- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
26-
2730 // Button types
2831 submitButtonType : 'submit' ,
29- normalButtonType : 'button' ,
3032
3133 // Component route url
3234 componentRouteUrl : '/ops/explorer' ,
@@ -42,6 +44,7 @@ const textConstants = {
4244const {
4345 diagnosticsAccordionItem,
4446 dropdownBlankValue,
47+ editToolbarButton,
4548 sambaDropdownValue,
4649 saveButton,
4750 cancelButton,
@@ -56,9 +59,8 @@ const {
5659 flashTypeSuccess,
5760 flashMessageSettingsSaved,
5861 flashMessageOperationCanceled,
59- buttonSelector,
6062 submitButtonType,
61- normalButtonType ,
63+ protocolSelectFieldId ,
6264} = textConstants ;
6365
6466function interceptAndAwaitApi ( {
@@ -99,12 +101,7 @@ function invokeAndAwaitEditEventForServer({ currentApiIntercepts }) {
99101 interceptAndAwaitApi ( {
100102 alias : 'editEventForServer' ,
101103 urlPattern : / \/ o p s \/ x _ b u t t o n \/ [ ^ / ] + \? p r e s s e d = .* l o g _ d e p o t _ e d i t / , // matches both /ops/x_button/1?pressed=log_depot_edit & /ops/x_button/2?pressed=zone_log_depot_edit endpoints
102- triggerFn : ( ) =>
103- cy
104- . get (
105- '.miq-toolbar-actions .miq-toolbar-group button[id$="log_depot_edit"]' // matches both buttons log_depot_edit & zone_log_depot_edit
106- )
107- . click ( ) ,
104+ triggerFn : ( ) => cy . toolbar ( editToolbarButton ) ,
108105 currentApiIntercepts,
109106 } ) ;
110107}
@@ -126,18 +123,16 @@ function resetProtocolDropdown({
126123 invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) ;
127124
128125 // Resetting Protocol dropdown value
129- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . then (
130- ( $select ) => {
131- const currentValue = $select . val ( ) ;
132- // If the value is not default one(BLANK_VALUE), then setting it to blank
133- if ( currentValue !== dropdownBlankValue ) {
134- cy . wrap ( $select ) . select ( dropdownBlankValue ) ;
135- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . click ( ) ;
136- // Validating confirmation flash message
137- cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
138- }
126+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( $select ) => {
127+ const currentValue = $select . val ( ) ;
128+ // If the value is not default one(BLANK_VALUE), then setting it to blank
129+ if ( currentValue !== dropdownBlankValue ) {
130+ cy . wrap ( $select ) . select ( dropdownBlankValue ) ;
131+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
132+ // Validating confirmation flash message
133+ cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
139134 }
140- ) ;
135+ } ) ;
141136}
142137
143138function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
@@ -153,45 +148,35 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) {
153148
154149function cancelButtonValidation ( ) {
155150 // Click cancel button in the form
156- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton )
157- . should ( 'be.enabled' )
158- . click ( ) ;
151+ cy . getFormFooterButtonByType ( cancelButton ) . should ( 'be.enabled' ) . click ( ) ;
159152 // Validating confirmation flash message
160153 cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
161154}
162155
163156function resetButtonValidation ( ) {
164157 // Confirm Reset button is disabled initially
165- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
166- 'be.disabled'
167- ) ;
158+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
168159
169160 // Selecting Samba option from dropdown
170- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . select (
171- sambaDropdownValue
172- ) ;
161+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
173162 // Confirm Reset button is enabled once dropdown value is changed and then click on Reset
174- cy . contains ( buttonSelector ( normalButtonType ) , resetButton )
175- . should ( 'be.enabled' )
176- . click ( ) ;
163+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
177164 // Confirm dropdown has the old value
178- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . should (
165+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . should (
179166 'have.value' ,
180167 dropdownBlankValue
181168 ) ;
182169}
183170
184171function saveButtonValidation ( ) {
185172 // Confirm Save button is disabled initially
186- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . should (
173+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . should (
187174 'be.disabled'
188175 ) ;
189176 // Selecting Samba option from dropdown
190- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . select (
191- sambaDropdownValue
192- ) ;
177+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
193178 // Confirm Save button is enabled once dropdown value is changed and then click on Save
194- cy . contains ( buttonSelector ( submitButtonType ) , saveButton )
179+ cy . getFormFooterButtonByType ( saveButton , submitButtonType )
195180 . should ( 'be.enabled' )
196181 . click ( ) ;
197182 // Validating confirmation flash message
@@ -207,6 +192,7 @@ describe('Automate Collect logs Edit form operations', () => {
207192 beforeEach ( ( ) => {
208193 registeredApiIntercepts = { } ;
209194 cy . login ( ) ;
195+ cy . wait ( 500 ) ;
210196 // Navigate to Application settings and Select Diagnostics
211197 cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
212198 interceptAndAwaitApi ( {
0 commit comments