@@ -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,16 @@ 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 . 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 ) ;
139
134
}
140
- ) ;
135
+ } ) ;
141
136
}
142
137
143
138
function goToCollectLogsNavbarAndOpenEditForm ( registeredApiIntercepts ) {
@@ -153,45 +148,35 @@ function goToCollectLogsNavbarAndOpenEditForm(registeredApiIntercepts) {
153
148
154
149
function cancelButtonValidation ( ) {
155
150
// 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 ( ) ;
159
152
// Validating confirmation flash message
160
153
cy . expect_flash ( flashTypeSuccess , flashMessageOperationCanceled ) ;
161
154
}
162
155
163
156
function resetButtonValidation ( ) {
164
157
// Confirm Reset button is disabled initially
165
- cy . contains ( buttonSelector ( normalButtonType ) , resetButton ) . should (
166
- 'be.disabled'
167
- ) ;
158
+ cy . getFormFooterButtonByType ( resetButton ) . should ( 'be.disabled' ) ;
168
159
169
160
// 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 ) ;
173
162
// 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 ( ) ;
177
164
// Confirm dropdown has the old value
178
- cy . get ( '#log-depot-settings .bx--select select#log_protocol' ) . should (
165
+ cy . getFormSelectFieldById ( protocolSelectFieldId ) . should (
179
166
'have.value' ,
180
167
dropdownBlankValue
181
168
) ;
182
169
}
183
170
184
171
function saveButtonValidation ( ) {
185
172
// Confirm Save button is disabled initially
186
- cy . contains ( buttonSelector ( submitButtonType ) , saveButton ) . should (
173
+ cy . getFormFooterButtonByType ( saveButton , submitButtonType ) . should (
187
174
'be.disabled'
188
175
) ;
189
176
// 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 ) ;
193
178
// 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 )
195
180
. should ( 'be.enabled' )
196
181
. click ( ) ;
197
182
// Validating confirmation flash message
@@ -207,6 +192,7 @@ describe('Automate Collect logs Edit form operations', () => {
207
192
beforeEach ( ( ) => {
208
193
registeredApiIntercepts = { } ;
209
194
cy . login ( ) ;
195
+ cy . wait ( 500 ) ;
210
196
// Navigate to Application settings and Select Diagnostics
211
197
cy . menu ( settingsMenuOption , appSettingsMenuOption ) ;
212
198
interceptAndAwaitApi ( {
0 commit comments