@@ -7,15 +7,21 @@ import { MiscUtils } from '@opensearch-dashboards-test/opensearch-dashboards-tes
77import {
88 OSD_TEST_DOMAIN_ENDPOINT_URL ,
99 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 ,
1019} from '../../../../utils/dashboards/datasource-management-dashboards-plugin/constants' ;
1120
1221const miscUtils = new MiscUtils ( cy ) ;
1322// Get environment variables
1423const username = Cypress . env ( 'username' ) ;
1524const password = Cypress . env ( 'password' ) ;
16- const REGION = 'us-east-1' ;
17- const ACCESS_KEY = 'accessKey' ;
18- const SECRET_KEY = 'secretKey' ;
1925
2026if ( Cypress . env ( 'DATASOURCE_MANAGEMENT_ENABLED' ) ) {
2127 describe ( 'Create datasources' , ( ) => {
@@ -48,22 +54,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
4854
4955 describe ( 'Datasource can be created successfully' , ( ) => {
5056 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' ) ;
5458 cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_noauth' ) ;
5559 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' ) ;
6264 cy . get ( '[name="dataSourceDescription"]' ) . type (
6365 'cypress test no auth data source'
6466 ) ;
6567
66- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
68+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
6769 cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
6870 expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
6971 } ) ;
@@ -74,27 +76,24 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
7476 } ) ;
7577
7678 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' ) ;
8080 cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_auth' ) ;
8181 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 (
8687 username
8788 ) ;
88- cy . get ( '[data-test-subj=" createDataSourceFormPasswordField"] ') . type (
89+ cy . getElementByTestId ( ' createDataSourceFormPasswordField') . type (
8990 password
9091 ) ;
91- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
92- 'be.enabled'
93- ) ;
92+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
9493 cy . get ( '[name="dataSourceDescription"]' ) . type (
9594 'cypress test basic auth data source'
9695 ) ;
97- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
96+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
9897 cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
9998 expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
10099 } ) ;
@@ -105,34 +104,30 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
105104 } ) ;
106105
107106 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' ) ;
111108 cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_sigv4_es' ) ;
112109 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 (
123120 ACCESS_KEY
124121 ) ;
125- cy . get ( '[data-test-subj=" createDataSourceFormSecretKeyField"] ') . type (
122+ cy . getElementByTestId ( ' createDataSourceFormSecretKeyField') . type (
126123 SECRET_KEY
127124 ) ;
128- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
129- 'be.enabled'
130- ) ;
125+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
131126 cy . get ( '[name="dataSourceDescription"]' ) . type (
132127 'cypress test sigV4 data source'
133128 ) ;
134129
135- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
130+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
136131 cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
137132 expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
138133 } ) ;
@@ -144,34 +139,29 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
144139 } ) ;
145140
146141 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' ) ;
150143 cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_sigv4_aoss' ) ;
151144 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 (
162154 ACCESS_KEY
163155 ) ;
164- cy . get ( '[data-test-subj=" createDataSourceFormSecretKeyField"] ') . type (
156+ cy . getElementByTestId ( ' createDataSourceFormSecretKeyField') . type (
165157 SECRET_KEY
166158 ) ;
167- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
168- 'be.enabled'
169- ) ;
159+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.enabled' ) ;
170160 cy . get ( '[name="dataSourceDescription"]' ) . type (
171161 'cypress test sigV4 data source (Serverless)'
172162 ) ;
173163
174- cy . get ( '[data-test-subj=" createDataSourceButton"] ') . click ( ) ;
164+ cy . getElementByTestId ( ' createDataSourceButton') . click ( ) ;
175165 cy . wait ( '@createDataSourceRequest' ) . then ( ( interception ) => {
176166 expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
177167 } ) ;
@@ -246,19 +236,21 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
246236
247237 describe ( 'Username validation' , ( ) => {
248238 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 (
253244 'not.exist'
254245 ) ;
255246 } ) ;
256247
257248 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' )
262254 . focus ( )
263255 . blur ( ) ;
264256 cy . get (
@@ -267,10 +259,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
267259 } ) ;
268260
269261 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' )
274267 . type ( username )
275268 . blur ( ) ;
276269 cy . get (
@@ -281,19 +274,19 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
281274
282275 describe ( 'Password validation' , ( ) => {
283276 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 (
288280 'not.exist'
289281 ) ;
290282 } ) ;
291283
292284 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' )
297290 . focus ( )
298291 . blur ( ) ;
299292 cy . get (
@@ -302,10 +295,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
302295 } ) ;
303296
304297 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' )
309303 . type ( password )
310304 . blur ( ) ;
311305 cy . get (
@@ -316,22 +310,18 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
316310
317311 describe ( 'SigV4 AuthType: fields validation' , ( ) => {
318312 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 ( ) ;
325316 cy . get (
326317 'input[data-test-subj="createDataSourceFormRegionField"]:invalid'
327318 ) . should ( 'have.length' , 1 ) ;
328319 } ) ;
329320
330321 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' )
335325 . focus ( )
336326 . blur ( ) ;
337327 cy . get (
@@ -340,10 +330,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
340330 } ) ;
341331
342332 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' )
347336 . focus ( )
348337 . blur ( ) ;
349338 cy . get (
@@ -352,12 +341,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
352341 } ) ;
353342
354343 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' ) ;
361349 } ) ;
362350 } ) ;
363351
@@ -366,9 +354,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
366354 miscUtils . visitPage (
367355 'app/management/opensearch-dashboards/dataSources/create'
368356 ) ;
369- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
370- 'be.disabled'
371- ) ;
357+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
372358 } ) ;
373359
374360 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')) {
377363 'have.length' ,
378364 1
379365 ) ;
380- cy . get ( '[data-test-subj="createDataSourceButton"]' ) . should (
381- 'be.disabled'
382- ) ;
366+ cy . getElementByTestId ( 'createDataSourceButton' ) . should ( 'be.disabled' ) ;
383367 } ) ;
384368
385369 it ( 'validate if create data source button is not disabled only if there is no any field error' , ( ) => {
386370 cy . get ( '[name="dataSourceTitle"]' ) . type ( 'test_create_button' ) ;
387371 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 (
392377 'not.be.disabled'
393378 ) ;
394379 } ) ;
395380
396381 it ( 'cancel button should redirect to datasource listing page' , ( ) => {
397- cy . get ( '[data-test-subj=" cancelCreateDataSourceButton"] ') . click ( ) ;
382+ cy . getElementByTestId ( ' cancelCreateDataSourceButton') . click ( ) ;
398383 cy . location ( 'pathname' , { timeout : 6000 } ) . should (
399384 'include' ,
400385 'app/management/opensearch-dashboards/dataSources'
0 commit comments