@@ -7,15 +7,21 @@ import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-tes
7
7
import {
8
8
OSD_TEST_DOMAIN_ENDPOINT_URL ,
9
9
OSD_INVALID_ENDPOINT_URL ,
10
+ DATASOURCE_DELAY ,
11
+ REGION ,
12
+ ACCESS_KEY ,
13
+ SECRET_KEY ,
14
+ AUTH_TYPE_BASIC_AUTH ,
15
+ AUTH_TYPE_NO_AUTH ,
16
+ AUTH_TYPE_SIGV4 ,
17
+ SERVICE_TYPE_OPENSEARCH ,
18
+ SERVICE_TYPE_OPENSEARCH_SERVERLESS ,
10
19
} from '../../../../utils/dashboards/datasource-management-dashboards-plugin/constants' ;
11
20
12
21
const miscUtils = new MiscUtils ( cy ) ;
13
22
// Get environment variables
14
23
const username = Cypress . env ( 'username' ) ;
15
24
const password = Cypress . env ( 'password' ) ;
16
- const REGION = 'us-east-1' ;
17
- const ACCESS_KEY = 'accessKey' ;
18
- const SECRET_KEY = 'secretKey' ;
19
25
20
26
if ( Cypress . env ( 'DATASOURCE_MANAGEMENT_ENABLED' ) ) {
21
27
describe ( 'Create datasources' , ( ) => {
@@ -48,22 +54,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
48
54
49
55
describe ( 'Datasource can be created successfully' , ( ) => {
50
56
it ( 'with no auth and all required inputs' , ( ) => {
51
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
52
- 'be.disabled'
53
- ) ;
57
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
54
58
cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_noauth' ) ;
55
59
cy . get ( '[name="endpoint"]' ) . type ( OSD_TEST_DOMAIN_ENDPOINT_URL ) ;
56
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
57
- 'no_auth'
58
- ) ;
59
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
60
- 'be.enabled'
61
- ) ;
60
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
61
+ cy . get ( `button[id=${ AUTH_TYPE_NO_AUTH } ]` ) . click ( ) ;
62
+
63
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
62
64
cy . get ( '[name="dataSourceDescription"]' ) . type (
63
65
'cypress test no auth data source'
64
66
) ;
65
67
66
- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
68
+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
67
69
cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
68
70
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
69
71
} ) ;
@@ -74,27 +76,24 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
74
76
} ) ;
75
77
76
78
it ( 'with basic auth and all required inputs' , ( ) => {
77
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
78
- 'be.disabled'
79
- ) ;
79
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
80
80
cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_auth' ) ;
81
81
cy . get ( '[name="endpoint"]' ) . type ( OSD_TEST_DOMAIN_ENDPOINT_URL ) ;
82
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
83
- 'username_password'
84
- ) ;
85
- cy . get ( '[data-test-subj="createDataSourceFormUsernameField"]' ) . type (
82
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
83
+ cy . get ( `button[id=${ AUTH_TYPE_BASIC_AUTH } ]` )
84
+ . click ( )
85
+ . wait ( DATASOURCE_DELAY ) ;
86
+ cy . getElementByTestId ( 'createDataSourceFormUsernameField' ) . type (
86
87
username
87
88
) ;
88
- cy . get ( '[data-test-subj=" createDataSourceFormPasswordField"] ') . type (
89
+ cy . getElementByTestId ( ' createDataSourceFormPasswordField') . type (
89
90
password
90
91
) ;
91
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
92
- 'be.enabled'
93
- ) ;
92
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
94
93
cy . get ( '[name="dataSourceDescription"]' ) . type (
95
94
'cypress test basic auth data source'
96
95
) ;
97
- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
96
+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
98
97
cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
99
98
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
100
99
} ) ;
@@ -105,34 +104,30 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
105
104
} ) ;
106
105
107
106
it ( 'with sigV4 and all required inputs to connect to OpenSearch Service' , ( ) => {
108
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
109
- 'be.disabled'
110
- ) ;
107
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
111
108
cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_sigv4_es' ) ;
112
109
cy . get ( '[name="endpoint"]' ) . type ( OSD_TEST_DOMAIN_ENDPOINT_URL ) ;
113
- cy . get ( '[data-test-subj=" createDataSourceFormAuthTypeSelect"] ') . select (
114
- 'sigv4'
115
- ) ;
116
- cy . get ( '[data-test-subj="createDataSourceFormRegionField"]' ) . type (
117
- REGION
118
- ) ;
119
- cy . get (
120
- '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
121
- ) . select ( 'es' ) ;
122
- cy . get ( '[data-test-subj=" createDataSourceFormAccessKeyField"] ') . type (
110
+ cy . getElementByTestId ( ' createDataSourceFormAuthTypeSelect') . click ( ) ;
111
+ cy . get ( `button[id= ${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
112
+ cy . getElementByTestId ( 'createDataSourceFormRegionField' ) . type ( REGION ) ;
113
+ cy . getElementByTestId (
114
+ 'createDataSourceFormSigV4ServiceTypeSelect'
115
+ ) . click ( ) ;
116
+ cy . get ( `button[id= ${ SERVICE_TYPE_OPENSEARCH } ]` )
117
+ . click ( )
118
+ . wait ( DATASOURCE_DELAY ) ;
119
+ cy . getElementByTestId ( ' createDataSourceFormAccessKeyField') . type (
123
120
ACCESS_KEY
124
121
) ;
125
- cy . get ( '[data-test-subj=" createDataSourceFormSecretKeyField"] ') . type (
122
+ cy . getElementByTestId ( ' createDataSourceFormSecretKeyField') . type (
126
123
SECRET_KEY
127
124
) ;
128
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
129
- 'be.enabled'
130
- ) ;
125
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
131
126
cy . get ( '[name="dataSourceDescription"]' ) . type (
132
127
'cypress test sigV4 data source'
133
128
) ;
134
129
135
- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
130
+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
136
131
cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
137
132
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
138
133
} ) ;
@@ -144,34 +139,29 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
144
139
} ) ;
145
140
146
141
it ( 'with sigV4 and all required inputs to connect to OpenSearch Serverless Service' , ( ) => {
147
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
148
- 'be.disabled'
149
- ) ;
142
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
150
143
cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_sigv4_aoss' ) ;
151
144
cy . get ( '[name="endpoint"]' ) . type ( OSD_TEST_DOMAIN_ENDPOINT_URL ) ;
152
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
153
- 'sigv4'
154
- ) ;
155
- cy . get ( '[data-test-subj="createDataSourceFormRegionField"]' ) . type (
156
- REGION
157
- ) ;
158
- cy . get (
159
- '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
160
- ) . select ( 'aoss' ) ;
161
- cy . get ( '[data-test-subj="createDataSourceFormAccessKeyField"]' ) . type (
145
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
146
+ cy . get ( `button[id=${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
147
+ cy . getElementByTestId ( 'createDataSourceFormRegionField' ) . type ( REGION ) ;
148
+ cy . getElementByTestId ( 'createDataSourceFormSigV4ServiceTypeSelect' )
149
+ . click ( )
150
+ . get ( `button[id=${ SERVICE_TYPE_OPENSEARCH_SERVERLESS } ]` )
151
+ . click ( )
152
+ . wait ( DATASOURCE_DELAY ) ;
153
+ cy . getElementByTestId ( 'createDataSourceFormAccessKeyField' ) . type (
162
154
ACCESS_KEY
163
155
) ;
164
- cy . get ( '[data-test-subj=" createDataSourceFormSecretKeyField"] ') . type (
156
+ cy . getElementByTestId ( ' createDataSourceFormSecretKeyField') . type (
165
157
SECRET_KEY
166
158
) ;
167
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
168
- 'be.enabled'
169
- ) ;
159
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
170
160
cy . get ( '[name="dataSourceDescription"]' ) . type (
171
161
'cypress test sigV4 data source (Serverless)'
172
162
) ;
173
163
174
- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
164
+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
175
165
cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
176
166
expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
177
167
} ) ;
@@ -246,19 +236,21 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
246
236
247
237
describe ( 'Username validation' , ( ) => {
248
238
it ( 'validate that username field does not show when auth type is no auth' , ( ) => {
249
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
250
- 'no_auth'
251
- ) ;
252
- cy . get ( '[data-test-subj="createDataSourceFormUsernameField"]' ) . should (
239
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
240
+ cy . get ( `button[id=${ AUTH_TYPE_NO_AUTH } ]` )
241
+ . click ( )
242
+ . wait ( DATASOURCE_DELAY ) ;
243
+ cy . getElementByTestId ( 'createDataSourceFormUsernameField' ) . should (
253
244
'not.exist'
254
245
) ;
255
246
} ) ;
256
247
257
248
it ( 'validate that username is a required field when auth type is username & password' , ( ) => {
258
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
259
- 'username_password'
260
- ) ;
261
- cy . get ( '[data-test-subj="createDataSourceFormUsernameField"]' )
249
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
250
+ cy . get ( `button[id=${ AUTH_TYPE_BASIC_AUTH } ]` )
251
+ . click ( )
252
+ . wait ( DATASOURCE_DELAY ) ;
253
+ cy . getElementByTestId ( 'createDataSourceFormUsernameField' )
262
254
. focus ( )
263
255
. blur ( ) ;
264
256
cy . get (
@@ -267,10 +259,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
267
259
} ) ;
268
260
269
261
it ( 'validate that username field does not show any error when auth type is username & password and field is not empty' , ( ) => {
270
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
271
- 'username_password'
272
- ) ;
273
- cy . get ( '[data-test-subj="createDataSourceFormUsernameField"]' )
262
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
263
+ cy . get ( `button[id=${ AUTH_TYPE_BASIC_AUTH } ]` )
264
+ . click ( )
265
+ . wait ( DATASOURCE_DELAY ) ;
266
+ cy . getElementByTestId ( 'createDataSourceFormUsernameField' )
274
267
. type ( username )
275
268
. blur ( ) ;
276
269
cy . get (
@@ -281,19 +274,19 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
281
274
282
275
describe ( 'Password validation' , ( ) => {
283
276
it ( 'validate that password field does not show when auth type is no auth' , ( ) => {
284
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
285
- 'no_auth'
286
- ) ;
287
- cy . get ( '[data-test-subj="createDataSourceFormPasswordField"]' ) . should (
277
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
278
+ cy . get ( `button[id=${ AUTH_TYPE_NO_AUTH } ]` ) . click ( ) ;
279
+ cy . getElementByTestId ( 'createDataSourceFormPasswordField' ) . should (
288
280
'not.exist'
289
281
) ;
290
282
} ) ;
291
283
292
284
it ( 'validate that password is a required field when auth type is username & password' , ( ) => {
293
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
294
- 'username_password'
295
- ) ;
296
- cy . get ( '[data-test-subj="createDataSourceFormPasswordField"]' )
285
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
286
+ cy . get ( `button[id=${ AUTH_TYPE_BASIC_AUTH } ]` )
287
+ . click ( )
288
+ . wait ( DATASOURCE_DELAY ) ;
289
+ cy . getElementByTestId ( 'createDataSourceFormPasswordField' )
297
290
. focus ( )
298
291
. blur ( ) ;
299
292
cy . get (
@@ -302,10 +295,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
302
295
} ) ;
303
296
304
297
it ( 'validate that password field does not show any error when auth type is username & password and field is not empty' , ( ) => {
305
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
306
- 'username_password'
307
- ) ;
308
- cy . get ( '[data-test-subj="createDataSourceFormPasswordField"]' )
298
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
299
+ cy . get ( `button[id=${ AUTH_TYPE_BASIC_AUTH } ]` )
300
+ . click ( )
301
+ . wait ( DATASOURCE_DELAY ) ;
302
+ cy . getElementByTestId ( 'createDataSourceFormPasswordField' )
309
303
. type ( password )
310
304
. blur ( ) ;
311
305
cy . get (
@@ -316,22 +310,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
316
310
317
311
describe ( 'SigV4 AuthType: fields validation' , ( ) => {
318
312
it ( 'validate that region is a required field' , ( ) => {
319
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
320
- 'sigv4'
321
- ) ;
322
- cy . get ( '[data-test-subj="createDataSourceFormRegionField"]' )
323
- . focus ( )
324
- . blur ( ) ;
313
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
314
+ cy . get ( `button[id=${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
315
+ cy . getElementByTestId ( 'createDataSourceFormRegionField' ) . focus ( ) . blur ( ) ;
325
316
cy . get (
326
317
'input[data-test-subj="createDataSourceFormRegionField"]:invalid'
327
318
) . should ( 'have.length' , 1 ) ;
328
319
} ) ;
329
320
330
321
it ( 'validate that accessKey is a required field' , ( ) => {
331
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
332
- 'sigv4'
333
- ) ;
334
- cy . get ( '[data-test-subj="createDataSourceFormAccessKeyField"]' )
322
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
323
+ cy . get ( `button[id=${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
324
+ cy . getElementByTestId ( 'createDataSourceFormAccessKeyField' )
335
325
. focus ( )
336
326
. blur ( ) ;
337
327
cy . get (
@@ -340,10 +330,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
340
330
} ) ;
341
331
342
332
it ( 'validate that secretKey is a required field' , ( ) => {
343
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
344
- 'sigv4'
345
- ) ;
346
- cy . get ( '[data-test-subj="createDataSourceFormSecretKeyField"]' )
333
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
334
+ cy . get ( `button[id=${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
335
+ cy . getElementByTestId ( 'createDataSourceFormSecretKeyField' )
347
336
. focus ( )
348
337
. blur ( ) ;
349
338
cy . get (
@@ -352,12 +341,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
352
341
} ) ;
353
342
354
343
it ( 'validate that serviceName is a required field, and with default option rendered' , ( ) => {
355
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
356
- 'sigv4'
357
- ) ;
358
- cy . get (
359
- '[data-test-subj="createDataSourceFormSigV4ServiceTypeSelect"]'
360
- ) . should ( 'have.value' , 'es' ) ;
344
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
345
+ cy . get ( `button[id=${ AUTH_TYPE_SIGV4 } ]` ) . click ( ) . wait ( DATASOURCE_DELAY ) ;
346
+ cy . getElementByTestId (
347
+ 'createDataSourceFormSigV4ServiceTypeSelect'
348
+ ) . contains ( 'Amazon OpenSearch Service' ) ;
361
349
} ) ;
362
350
} ) ;
363
351
@@ -366,9 +354,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
366
354
miscUtils . visitPage (
367
355
'app/management/opensearch-dashboards/dataSources/create'
368
356
) ;
369
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
370
- 'be.disabled'
371
- ) ;
357
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
372
358
} ) ;
373
359
374
360
it ( 'validate if create data source button is disabled when there is any field error' , ( ) => {
@@ -377,24 +363,23 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
377
363
'have.length' ,
378
364
1
379
365
) ;
380
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
381
- 'be.disabled'
382
- ) ;
366
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
383
367
} ) ;
384
368
385
369
it ( 'validate if create data source button is not disabled only if there is no any field error' , ( ) => {
386
370
cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_create_button' ) ;
387
371
cy . get ( '[name="endpoint"]' ) . type ( OSD_TEST_DOMAIN_ENDPOINT_URL ) ;
388
- cy . get ( '[data-test-subj="createDataSourceFormAuthTypeSelect"]' ) . select (
389
- 'no_auth'
390
- ) ;
391
- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
372
+ cy . getElementByTestId ( 'createDataSourceFormAuthTypeSelect' ) . click ( ) ;
373
+ cy . get ( `button[id=${ AUTH_TYPE_NO_AUTH } ]` )
374
+ . click ( )
375
+ . wait ( DATASOURCE_DELAY ) ;
376
+ cy . getElementByTestId ( 'createDataSourceButton' ) . should (
392
377
'not.be.disabled'
393
378
) ;
394
379
} ) ;
395
380
396
381
it ( 'cancel button should redirect to datasource listing page' , ( ) => {
397
- cy . get ( '[data-test-subj=" cancelCreateDataSourceButton"] ') . click ( ) ;
382
+ cy . getElementByTestId ( ' cancelCreateDataSourceButton') . click ( ) ;
398
383
cy . location ( 'pathname' , { timeout : 6000 } ) . should (
399
384
'include' ,
400
385
'app/management/opensearch-dashboards/dataSources'
0 commit comments