Skip to content

Commit 85596b2

Browse files
authored
[Datasource Management] Cypress test fix (#1763)
* fix the path in test 1 Signed-off-by: Jialiang Liang <[email protected]> * fix the action Signed-off-by: Jialiang Liang <[email protected]> * correct all the link for opensearch conneciton creation Signed-off-by: Jialiang Liang <[email protected]> * fix 2_datasource_table.spec.js Signed-off-by: Jialiang Liang <[email protected]> * fix the test 1 again for some url mismatch Signed-off-by: Jialiang Liang <[email protected]> * fix the test 3 Signed-off-by: Jialiang Liang <[email protected]> --------- Signed-off-by: Jialiang Liang <[email protected]>
1 parent bfd6ced commit 85596b2

File tree

4 files changed

+31
-44
lines changed

4 files changed

+31
-44
lines changed

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/1_create_datasource.spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
3232
beforeEach(() => {
3333
// Visit OSD create page
3434
miscUtils.visitPage(
35-
'app/management/opensearch-dashboards/dataSources/create'
35+
'app/management/opensearch-dashboards/dataSources/configure/OpenSearch'
3636
);
3737

3838
cy.intercept('POST', '/api/saved_objects/data-source').as(
@@ -360,7 +360,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
360360
describe('Cancel button and create data source button', () => {
361361
it('validate if create data source button is disabled when first visit this page', () => {
362362
miscUtils.visitPage(
363-
'app/management/opensearch-dashboards/dataSources/create'
363+
'app/management/opensearch-dashboards/dataSources/configure/OpenSearch'
364364
);
365365
cy.getElementByTestId('createDataSourceButton').should('be.disabled');
366366
});
@@ -386,11 +386,11 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
386386
);
387387
});
388388

389-
it('cancel button should redirect to datasource listing page', () => {
389+
it('cancel button should redirect to centralized datasource creation page', () => {
390390
cy.getElementByTestId('cancelCreateDataSourceButton').click();
391391
cy.location('pathname', { timeout: 6000 }).should(
392392
'include',
393-
'app/management/opensearch-dashboards/dataSources'
393+
'app/management/opensearch-dashboards/dataSources/create'
394394
);
395395
});
396396
});

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/2_datasource_table.spec.js

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
3333
});
3434

3535
it('should successfully load the page', () => {
36-
cy.contains(
37-
'Create and manage data source connections to help you retrieve data from multiple OpenSearch compatible sources.',
38-
TIMEOUT_OPTS
39-
);
36+
cy.contains('Create and manage data source connections.', TIMEOUT_OPTS);
4037
});
4138

4239
describe('Empty State', () => {
@@ -120,7 +117,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
120117
// Get the datasource table header and click it to sort sscending first
121118
cy.getColumnHeaderByNameAndClickForSorting(
122119
tableHeadIdentifier,
123-
'Title'
120+
'Data source'
124121
);
125122

126123
// Confirm we have ds_a in view and not ds_z
@@ -133,7 +130,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
133130
// Get the datasource table header and click it to sort descending first
134131
cy.getColumnHeaderByNameAndClickForSorting(
135132
tableHeadIdentifier,
136-
'Title'
133+
'Data source'
137134
);
138135

139136
// Confirm we have ds_z in view and not ds_a
@@ -143,7 +140,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
143140
// sort to ascending order for next steps
144141
cy.getColumnHeaderByNameAndClickForSorting(
145142
tableHeadIdentifier,
146-
'Title'
143+
'Data source'
147144
);
148145
});
149146
});
@@ -294,20 +291,16 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
294291
});
295292
});
296293
describe('Selection & Deletion', () => {
297-
it('should not select any rows by default & delete button should be disabled', () => {
294+
it('should not select any rows by default & delete button should not exist', () => {
298295
cy.getElementByTestId('deleteDataSourceConnections').should(
299-
'be.disabled'
300-
);
301-
cy.getElementByTestId('deleteDataSourceConnections').should(
302-
'contain.text',
303-
'Delete '
296+
'not.exist'
304297
);
305298
});
306299

307300
it('should verify simple selection & un-selection of rows', () => {
308301
// Verify that delete button is disabled
309302
cy.getElementByTestId('deleteDataSourceConnections').should(
310-
'be.disabled'
303+
'not.exist'
311304
);
312305
// Select first 2 rows
313306
cy.get('tbody > tr > td.euiTableRowCellCheckbox [type="checkbox"]')
@@ -317,10 +310,8 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
317310
.eq(1)
318311
.check();
319312

320-
// Verify tha delete button is not disabled & displays expected text
321-
cy.getElementByTestId('deleteDataSourceConnections').should(
322-
'not.be.disabled'
323-
);
313+
// Verify tha delete button exists & displays expected text
314+
cy.getElementByTestId('deleteDataSourceConnections').should('exist');
324315
cy.getElementByTestId('deleteDataSourceConnections').should(
325316
'contain.text',
326317
'Delete 2 connections'
@@ -334,13 +325,13 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
334325
.eq(1)
335326
.uncheck();
336327
cy.getElementByTestId('deleteDataSourceConnections').should(
337-
'be.disabled'
328+
'not.exist'
338329
);
339330
});
340331

341332
it('should select single row & perform delete', () => {
342333
cy.getElementByTestId('deleteDataSourceConnections').should(
343-
'be.disabled'
334+
'not.exist'
344335
);
345336
cy.contains('ds_a').should('exist');
346337

@@ -357,15 +348,15 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
357348
cy.getElementByTestId('deleteDataSourceConnections').click();
358349
cy.getElementByTestId('confirmModalConfirmButton').click();
359350
cy.contains('ds_a').should('not.exist');
351+
// after deletion, delete button should not exist since there is no row being selected
360352
cy.getElementByTestId('deleteDataSourceConnections').should(
361-
'contain.text',
362-
'Delete '
353+
'not.exist'
363354
);
364355
});
365356

366357
it('should select multiple rows & perform delete', () => {
367358
cy.getElementByTestId('deleteDataSourceConnections').should(
368-
'be.disabled'
359+
'not.exist'
369360
);
370361
cy.contains('ds_b').should('exist');
371362

@@ -395,9 +386,9 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
395386
cy.getElementByTestId('deleteDataSourceConnections').click();
396387
cy.getElementByTestId('confirmModalConfirmButton').click();
397388
cy.contains('ds_b').should('not.exist');
389+
// after deletion, delete button should not exist since there is no row being selected
398390
cy.getElementByTestId('deleteDataSourceConnections').should(
399-
'contain.text',
400-
'Delete '
391+
'not.exist'
401392
);
402393
cy.get('li.euiPagination__item').should(($li) => {
403394
expect($li).to.have.length(2); // 2 pages
@@ -419,9 +410,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
419410
'contain.text',
420411
'Delete 10 connections'
421412
);
422-
cy.getElementByTestId('deleteDataSourceConnections').should(
423-
'not.be.disabled'
424-
);
413+
cy.getElementByTestId('deleteDataSourceConnections').should('exist');
425414

426415
// sort by description column
427416
cy.getColumnHeaderByNameAndClickForSorting(
@@ -430,7 +419,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
430419
);
431420

432421
cy.getElementByTestId('deleteDataSourceConnections').should(
433-
'be.disabled'
422+
'not.exist'
434423
);
435424
});
436425

@@ -449,7 +438,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
449438
cy.getElementByTestId('pagination-button-next').click();
450439

451440
cy.getElementByTestId('deleteDataSourceConnections').should(
452-
'be.disabled'
441+
'not.exist'
453442
);
454443
});
455444

@@ -468,18 +457,21 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
468457
cy.get(searchFieldIdentifier).focus().clear().type('ds_z');
469458

470459
cy.getElementByTestId('deleteDataSourceConnections').should(
471-
'be.disabled'
460+
'not.exist'
472461
);
473462
});
474463
});
475464

476465
/* Create button*/
477466
describe('create button', () => {
478467
it('should navigate to create data source on button click', () => {
468+
// should vist the centralized creation page first
479469
cy.getElementByTestId('createDataSourceButton').first().click();
470+
// clicking the 'opensearch' card button
471+
cy.getElementByTestId('datasource_card_opensearch').first().click();
480472
cy.location('pathname').should(
481473
'eq',
482-
'/app/management/opensearch-dashboards/dataSources/create'
474+
'/app/management/opensearch-dashboards/dataSources/configure/OpenSearch'
483475
);
484476
});
485477
});

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/datasource-management-plugin/3_update_datasource.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ if (Cypress.env('DATASOURCE_MANAGEMENT_ENABLED')) {
5858
});
5959

6060
it('should successfully load the listing page & have 2 records in table', () => {
61-
cy.contains(
62-
'Create and manage data source connections to help you retrieve data from multiple OpenSearch compatible sources.'
63-
);
61+
cy.contains('Create and manage data source connections.');
6462
// Confirm we have 2 rows in the table
6563
cy.get('tbody > tr').should(($tr) => {
6664
expect($tr).to.have.length(2);

cypress/utils/dashboards/datasource-management-dashboards-plugin/commands.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@ Cypress.Commands.add('visitDataSourcesListingPage', () => {
139139
miscUtils.visitPage('app/management/opensearch-dashboards/dataSources');
140140

141141
// Common text to wait for to confirm page loaded, give up to 60 seconds for initial load
142-
cy.contains(
143-
'Create and manage data source connections to help you retrieve data from multiple OpenSearch compatible sources.',
144-
{ timeout: 60000 }
145-
);
142+
cy.contains('Create and manage data source connections.', { timeout: 60000 });
146143
});
147144

148145
Cypress.Commands.add(
@@ -249,7 +246,7 @@ Cypress.Commands.add('viewDataSourceAggregatedView', (dataSourceTitle) => {
249246

250247
Cypress.Commands.add('createDataSourceNoAuthWithTitle', (title) => {
251248
miscUtils.visitPage(
252-
'app/management/opensearch-dashboards/dataSources/create'
249+
'app/management/opensearch-dashboards/dataSources/configure/OpenSearch'
253250
);
254251

255252
cy.intercept('POST', '/api/saved_objects/data-source').as(

0 commit comments

Comments
 (0)