@@ -12,21 +12,23 @@ const textConstants = {
12
12
zoneAccordItem : / ^ Z o n e : / ,
13
13
serverAccordItem : / ^ S e r v e r : / ,
14
14
15
+ // Config options
16
+ editToolbarButton : 'Edit' ,
17
+
15
18
// Buttons
16
19
saveButton : 'Save' ,
17
20
cancelButton : 'Cancel' ,
18
21
resetButton : 'Reset' ,
19
22
23
+ // Common element IDs
24
+ protocolSelectFieldId : 'log_protocol' ,
25
+
20
26
// Dropdown values
21
27
dropdownBlankValue : 'BLANK_VALUE' ,
22
28
sambaDropdownValue : 'FileDepotSmb' ,
23
29
24
- // Common selectors
25
- buttonSelector : ( type ) => `#main-content .bx--btn-set button[type="${ type } "]` ,
26
-
27
30
// Button types
28
31
submitButtonType : 'submit' ,
29
- normalButtonType : 'button' ,
30
32
31
33
// Component route url
32
34
componentRouteUrl : '/ops/explorer' ,
@@ -42,6 +44,7 @@ const textConstants = {
42
44
const {
43
45
diagnosticsAccordionItem,
44
46
dropdownBlankValue,
47
+ editToolbarButton,
45
48
sambaDropdownValue,
46
49
saveButton,
47
50
cancelButton,
@@ -56,9 +59,8 @@ const {
56
59
flashTypeSuccess,
57
60
flashMessageSettingsSaved,
58
61
flashMessageOperationCanceled,
59
- buttonSelector,
60
62
submitButtonType,
61
- normalButtonType ,
63
+ protocolSelectFieldId ,
62
64
} = textConstants ;
63
65
64
66
function interceptAndAwaitApi ( {
@@ -99,12 +101,7 @@ function invokeAndAwaitEditEventForServer({ currentApiIntercepts }) {
99
101
interceptAndAwaitApi ( {
100
102
alias : 'editEventForServer' ,
101
103
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 ) ,
108
105
currentApiIntercepts,
109
106
} ) ;
110
107
}
@@ -126,18 +123,17 @@ function resetProtocolDropdown({
126
123
invokeAndAwaitEditEventForServer ( { currentApiIntercepts } ) ;
127
124
128
125
// 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 ) ;
139
135
}
140
- ) ;
136
+ } ) ;
141
137
}
142
138
143
139
function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
@@ -153,45 +149,35 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) {
153
149
154
150
function cancelButtonValidation ( ) {
155
151
// 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 ( ) ;
159
153
// Validating confirmation flash message
160
154
cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
161
155
}
162
156
163
157
function resetButtonValidation ( ) {
164
158
// Confirm Reset button is disabled initially
165
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
166
- 'be.disabled'
167
- ) ;
159
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
168
160
169
161
// 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 ) ;
173
163
// 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 ( ) ;
177
165
// Confirm dropdown has the old value
178
- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . should (
166
+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . should (
179
167
'have.value' ,
180
168
dropdownBlankValue
181
169
) ;
182
170
}
183
171
184
172
function saveButtonValidation ( ) {
185
173
// Confirm Save button is disabled initially
186
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . should (
174
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . should (
187
175
'be.disabled'
188
176
) ;
189
177
// 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 ) ;
193
179
// 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 )
195
181
. should ( 'be.enabled' )
196
182
. click ( ) ;
197
183
// Validating confirmation flash message
@@ -207,6 +193,7 @@ describe('Automate Collect logs Edit form operations', () => {
207
193
beforeEach ( ( ) => {
208
194
registeredApiIntercepts = { } ;
209
195
cy . login ( ) ;
196
+ cy . wait ( 500 ) ;
210
197
// Navigate to Application settings and Select Diagnostics
211
198
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
212
199
interceptAndAwaitApi ( {
0 commit comments