@@ -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,17 @@ 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.get('#log-depot-settings .bx--select select#log_protocol')
127+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . then ( ( $select ) => {
128+ const currentValue = $select . val ( ) ;
129+ // If the value is not default one(BLANK_VALUE), then setting it to blank
130+ if ( currentValue !== dropdownBlankValue ) {
131+ cy . wrap ( $select ) . select ( dropdownBlankValue ) ;
132+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . click ( ) ;
133+ // Validating confirmation flash message
134+ cy . expect_flash ( flashTypeSuccess , flashMessageSettingsSaved ) ;
139135 }
140- ) ;
136+ } ) ;
141137}
142138
143139function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
@@ -153,45 +149,35 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) {
153149
154150function cancelButtonValidation ( ) {
155151 // Click cancel button in the form
156- cy . contains ( buttonSelector ( normalButtonType ) , cancelButton )
157- . should ( 'be.enabled' )
158- . click ( ) ;
152+ cy . getFormFooterButtonByType ( cancelButton ) . should ( 'be.enabled' ) . click ( ) ;
159153 // Validating confirmation flash message
160154 cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
161155}
162156
163157function resetButtonValidation ( ) {
164158 // Confirm Reset button is disabled initially
165- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
166- 'be.disabled'
167- ) ;
159+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
168160
169161 // Selecting Samba option from dropdown
170- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . select (
171- sambaDropdownValue
172- ) ;
162+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
173163 // 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 ( ) ;
164+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.enabled' ) . click ( ) ;
177165 // Confirm dropdown has the old value
178- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . should (
166+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . should (
179167 'have.value' ,
180168 dropdownBlankValue
181169 ) ;
182170}
183171
184172function saveButtonValidation ( ) {
185173 // Confirm Save button is disabled initially
186- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . should (
174+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . should (
187175 'be.disabled'
188176 ) ;
189177 // Selecting Samba option from dropdown
190- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . select (
191- sambaDropdownValue
192- ) ;
178+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . select ( sambaDropdownValue ) ;
193179 // Confirm Save button is enabled once dropdown value is changed and then click on Save
194- cy . contains ( buttonSelector ( submitButtonType ) , saveButton )
180+ cy . getFormFooterButtonByType ( saveButton , submitButtonType )
195181 . should ( 'be.enabled' )
196182 . click ( ) ;
197183 // Validating confirmation flash message
@@ -207,6 +193,7 @@ describe('Automate Collect logs Edit form operations', () => {
207193 beforeEach ( ( ) => {
208194 registeredApiIntercepts = { } ;
209195 cy . login ( ) ;
196+ cy . wait ( 500 ) ;
210197 // Navigate to Application settings and Select Diagnostics
211198 cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
212199 interceptAndAwaitApi ( {
0 commit comments