Skip to content

Commit 8c81484

Browse files
AMoo-Mikiashwin-pc
andauthored
Updates tests to visBuilder key (opensearch-project#361) (opensearch-project#365)
Signed-off-by: Ashwin Pc <ashwinpc@amazon.com> Signed-off-by: Ashwin Pc <ashwinpc@amazon.com> (cherry picked from commit 89b9c35) Co-authored-by: Ashwin P Chandran <ashwinpc@amazon.com>
1 parent 3b50b7b commit 8c81484

File tree

15 files changed

+20131
-20062
lines changed

15 files changed

+20131
-20062
lines changed

.github/workflows/cypress-workflow-bundle-snapshot-based.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ jobs:
2929
with:
3030
test-name: Core Dashboards using Bundle Snapshot
3131
test-command: env CYPRESS_VISBUILDER_ENABLED=true CYPRESS_DATASOURCE_MANAGEMENT_ENABLED=true yarn cypress:run-with-security --browser chromium --spec 'cypress/integration/core-opensearch-dashboards/opensearch-dashboards/**/*.js'
32-
osd-serve-args: --wizard.enabled=true --data_source.enabled=true
32+
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true

CONTRIBUTING.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
- [Run Tests](#run-tests)
66
- [Formatting](#formatting)
77
- [Onboarding](#onboarding)
8+
- [Test Development](#test-development)
9+
- [Experimental Features](#experimental-features)
10+
- [Release](#release)
811
- [First Things First](#first-things-first)
912
- [Ways to Contribute](#ways-to-contribute)
1013
- [Bug Reports](#bug-reports)
@@ -171,7 +174,7 @@ Add an environment variable (e.g boolean) to only run tests for the experiementa
171174

172175
3. Set up Github action to run the tests inside the current repo
173176

174-
Create a new workflow by referring to [this template](https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/.github/workflows/release-e2e-workflow-template.yml) for OSD plugin or [this workflow](https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/.github/workflows/cypress-workflow-vanilla-snapshot-based.yml) for OSD Core. This workflow is to run the OSD from artifact. You could enable your experimental feature through either `./bin/opensearch-dashboards --wizard.enabled` or through modifying the content of the yml file. (In order to run the tests from the source code repo of the feature, you can set up workflows to check out the source code and use `yarn` to start OSD.)
177+
Create a new workflow by referring to [this template](https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/.github/workflows/release-e2e-workflow-template.yml) for OSD plugin or [this workflow](https://github.com/opensearch-project/opensearch-dashboards-functional-test/blob/main/.github/workflows/cypress-workflow-vanilla-snapshot-based.yml) for OSD Core. This workflow is to run the OSD from artifact. You could enable your experimental feature through either `./bin/opensearch-dashboards --vis_builder.enabled` or through modifying the content of the yml file. (In order to run the tests from the source code repo of the feature, you can set up workflows to check out the source code and use `yarn` to start OSD.)
175178

176179
4. Run tests from `opensearch-build`
177180

cypress/fixtures/dashboard/opensearch_dashboards/visBuilder/vb_saved_objects.ndjson

+7-6
Large diffs are not rendered by default.

cypress/fixtures/dashboard/opensearch_dashboards/visBuilder/vis-builder.data.txt

+20,000
Large diffs are not rendered by default.

cypress/fixtures/dashboard/opensearch_dashboards/visBuilder/vis_builder.data.txt

-20,000
This file was deleted.

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/basic.spec.js

+48-11
Original file line numberDiff line numberDiff line change
@@ -15,36 +15,41 @@ import {
1515
VB_METRIC_VIS_TITLE,
1616
VB_PATH_INDEX_DATA,
1717
VB_PATH_SO_DATA,
18+
VB_SO_TYPE,
1819
} from '../../../../../utils/constants';
1920

2021
if (Cypress.env('VISBUILDER_ENABLED')) {
2122
describe('Visualization Builder Base Tests', () => {
2223
before(() => {
2324
cy.deleteIndex(VB_INDEX_ID);
24-
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
25+
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
2526
cy.importSavedObjects(VB_PATH_SO_DATA);
2627
});
2728

28-
it('Show existing visualizations in Visualize', () => {
29+
it('Show existing visualizations in Visualize and navigate to it', () => {
2930
cy.visit(`${BASE_PATH}/app/visualize`);
3031
cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`);
32+
cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop
3133
cy.getElementByTestId(
3234
`visListingTitleLink-${toTestId(VB_METRIC_VIS_TITLE)}`
33-
).should('exist');
35+
)
36+
.should('exist')
37+
.click();
38+
cy.location('pathname').should('contain', VB_APP_PATH);
3439
});
3540

36-
it('Navigate to Visualization Builder from Visualize', () => {
41+
it('Navigate to Visualization Builder from Create Visualization', () => {
3742
cy.visit(`${BASE_PATH}/app/visualize`);
3843
cy.getElementByTestId('newItemButton').click();
39-
cy.getElementByTestId('visType-wizard').click();
44+
cy.getElementByTestId('visType-vis-builder').click();
4045
cy.location('pathname').should('eq', VB_APP_PATH);
4146
});
4247

4348
it('Create new basic metric visualization', () => {
4449
cy.visit(VB_APP_URL);
4550

4651
// Wait for page to load
47-
cy.getElementByTestId('homeIcon');
52+
cy.waitForLoader();
4853
cy.vbSelectDataSource(VB_INDEX_PATTERN);
4954

5055
// Set Top nav
@@ -59,19 +64,19 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
5964
.should('contain.text', VB_INDEX_DOC_COUNT);
6065

6166
// Update Topnav
62-
cy.setTopNavQuery('age < 50');
67+
cy.setTopNavQuery('salary < 15000');
6368

6469
// See if the value updated
6570
cy.getElementByTestId('visualizationLoader')
6671
.find('.mtrVis__value')
67-
.should('contain.text', `4,390`);
72+
.should('contain.text', `5,000`);
6873
});
6974

7075
it('Be able to add/ edit and remove a field', () => {
7176
cy.visit(VB_APP_URL);
7277

7378
// Wait for page to load
74-
cy.getElementByTestId('homeIcon');
79+
cy.waitForLoader();
7580
cy.vbSelectDataSource(VB_INDEX_PATTERN);
7681
cy.vbSelectVisType('Metric');
7782

@@ -85,14 +90,19 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
8590
{
8691
testSubj: 'defaultEditorAggSelect',
8792
type: 'select',
88-
value: 'Average',
93+
value: 'Min',
94+
},
95+
{
96+
testSubj: 'visDefaultEditorField',
97+
type: 'select',
98+
value: 'age',
8999
},
90100
]);
91101

92102
// Check if add worked
93103
cy.getElementByTestId('visualizationLoader')
94104
.find('.mtrVis__value')
95-
.should('contain.text', '54.912');
105+
.should('contain.text', '10');
96106

97107
cy.getElementByTestId('dropBoxField-metric-0').click();
98108
cy.vbEditAgg([
@@ -116,6 +126,33 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
116126
cy.getElementByTestId('emptyWorkspace').should('exist');
117127
});
118128

129+
it('Be able to save a visualization', () => {
130+
cy.visit(VB_APP_URL);
131+
132+
// Wait for page to load
133+
cy.waitForLoader();
134+
cy.vbSelectDataSource(VB_INDEX_PATTERN);
135+
136+
// Create basic vis
137+
cy.getElementByTestId('field-undefined-showDetails').drag(
138+
'[data-test-subj=dropBoxAddField-metric]'
139+
);
140+
141+
// Save
142+
const cleanupKey = Date.now();
143+
const title = `VB: vb${cleanupKey}`;
144+
cy.getElementByTestId('visBuilderSaveButton')
145+
.should('not.be.disabled')
146+
.click();
147+
cy.getElementByTestId('savedObjectTitle').type(title + '{enter}');
148+
149+
// Verify save
150+
cy.location('pathname').should('contain', VB_APP_PATH + '/edit');
151+
152+
// Cleanup
153+
cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`);
154+
});
155+
119156
after(() => {
120157
cy.deleteIndex(VB_INDEX_ID);
121158
});

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/dashboard.spec.js

+23-12
Original file line numberDiff line numberDiff line change
@@ -7,40 +7,49 @@ import {
77
VB_INDEX_PATTERN,
88
VB_INDEX_ID,
99
VB_DASHBOARD_ID,
10-
VB_METRIC_EMBEDDABLE_ID,
11-
VB_BAR_EMBEDDABLE_ID,
1210
toTestId,
1311
VB_INDEX_DOC_COUNT,
1412
VB_INDEX_START_TIME,
1513
VB_INDEX_END_TIME,
1614
VB_PATH_INDEX_DATA,
1715
VB_PATH_SO_DATA,
1816
VB_LINE_VIS_TITLE,
17+
VB_SO_TYPE,
18+
VB_METRIC_VIS_TITLE,
19+
VB_BAR_VIS_TITLE,
1920
} from '../../../../../utils/constants';
2021

2122
if (Cypress.env('VISBUILDER_ENABLED')) {
2223
describe('Visualization Builder Dashboard Tests', () => {
2324
before(() => {
2425
cy.deleteIndex(VB_INDEX_ID);
25-
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
26+
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
2627

2728
cy.importSavedObjects(VB_PATH_SO_DATA);
2829

2930
cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`);
3031

3132
// Wait for page to load
32-
cy.getElementByTestId('homeIcon');
33+
cy.waitForLoader();
3334

3435
cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME);
3536
});
3637

3738
it('Should have valid visualizations', () => {
38-
cy.get(`[data-test-embeddable-id="${VB_METRIC_EMBEDDABLE_ID}"]`)
39+
cy.getElementByTestId(
40+
`embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}`
41+
)
42+
.should('contain.text', VB_METRIC_VIS_TITLE)
43+
.siblings('.embPanel__content')
3944
.find('.mtrVis__value')
4045
.should('contain.text', VB_INDEX_DOC_COUNT); // Total no of record in the sample daa
41-
cy.get(`[data-test-embeddable-id="${VB_BAR_EMBEDDABLE_ID}"]`)
46+
cy.getElementByTestId(
47+
`embeddablePanelHeading-${toTestId(VB_BAR_VIS_TITLE, '')}`
48+
)
49+
.should('contain.text', VB_BAR_VIS_TITLE)
50+
.siblings('.embPanel__content')
4251
.find('.visLegend__valueTitle')
43-
.should('contain.text', `Count`);
52+
.should('contain.text', `Median`);
4453
});
4554

4655
it('Should be able to add a visualization', () => {
@@ -67,7 +76,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
6776
// Create new Vis Builder Visualisation
6877
cy.getElementByTestId('dashboardEditMode').click();
6978
cy.getElementByTestId('dashboardAddNewPanelButton').click();
70-
cy.getElementByTestId('visType-wizard').click();
79+
cy.getElementByTestId('visType-vis-builder').click();
7180

7281
// Create a metric visualisation
7382
cy.vbSelectDataSource(VB_INDEX_PATTERN);
@@ -79,7 +88,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
7988
// Save and return
8089
const cleanupKey = Date.now();
8190
const visTitle = `VB: New Dashboard Visualization - vb${cleanupKey}`;
82-
cy.getElementByTestId('wizardSaveButton')
91+
cy.getElementByTestId('visBuilderSaveButton')
8392
.should('not.be.disabled')
8493
.click();
8594
cy.getElementByTestId('savedObjectTitle').type(visTitle);
@@ -93,13 +102,15 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
93102
// Cleanup
94103
cy.getElementByTestId('dashboardViewOnlyMode').click();
95104
cy.getElementByTestId('confirmModalConfirmButton').click();
96-
cy.deleteSavedObjectByType('wizard', `vb${cleanupKey}`);
105+
cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`);
97106
});
98107

99108
it('Should be able to edit a visualization', () => {
100109
// Navigate to vis builder
101110
cy.getElementByTestId('dashboardEditMode').click();
102-
cy.get(`[data-test-embeddable-id="${VB_METRIC_EMBEDDABLE_ID}"]`)
111+
cy.getElementByTestId(
112+
`embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}`
113+
)
103114
.find('[data-test-subj="embeddablePanelToggleMenuIcon"]')
104115
.click();
105116
cy.getElementByTestId('embeddablePanelAction-editPanel').click();
@@ -119,7 +130,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
119130
]);
120131

121132
// Save and return
122-
cy.getElementByTestId('wizardsaveAndReturnButton').click();
133+
cy.getElementByTestId('visBuilderSaveAndReturnButton').click();
123134

124135
cy.getElementByTestId('visualizationLoader').should(
125136
'contain.text',

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/experimental.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
3838

3939
// Check Create visualization modal
4040
cy.getElementByTestId('newItemButton').click();
41-
cy.getElementByTestId(['visType-wizard'])
41+
cy.getElementByTestId(['visType-vis-builder'])
4242
.find('.euiKeyPadMenuItem__betaBadge')
4343
.should('exist');
4444
});
@@ -55,11 +55,11 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
5555

5656
// Check Create visualization modal
5757
cy.getElementByTestId('newItemButton').click();
58-
cy.getElementByTestId(['visType-wizard']).should('exist');
58+
cy.getElementByTestId(['visType-vis-builder']).should('exist');
5959

6060
// Check Dashboard
6161
cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`);
62-
cy.getElementByTestId('wizardLoader').should('exist');
62+
cy.getElementByTestId('visBuilderLoader').should('exist');
6363
});
6464

6565
it('Sould handle experimental setting turned off', () => {
@@ -74,7 +74,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
7474

7575
// Check Create visualization modal
7676
cy.getElementByTestId('newItemButton').click();
77-
cy.getElementByTestId(['visType-wizard']).should('not.exist');
77+
cy.getElementByTestId(['visType-vis-builder']).should('not.exist');
7878

7979
// Check Dashboard
8080
cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`);

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/area.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
1717
describe('Vis Builder: Line Chart', () => {
1818
before(() => {
1919
cy.deleteIndex(VB_INDEX_ID);
20-
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
20+
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
2121
cy.importSavedObjects(VB_PATH_SO_DATA);
2222

2323
cy.visit(VB_APP_URL);
2424

2525
// Wait for page to load
26-
cy.getElementByTestId('homeIcon');
26+
cy.waitForLoader();
2727
cy.vbSelectDataSource(VB_INDEX_PATTERN);
2828

2929
// Set Top nav
@@ -33,13 +33,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
3333
});
3434

3535
it('Basic test', () => {
36-
cy.getElementByTestId('field-age-showDetails').drag(
36+
cy.getElementByTestId('field-salary-showDetails').drag(
3737
'[data-test-subj="dropBoxAddField-metric"]'
3838
);
39-
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
39+
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
4040
'[data-test-subj="dropBoxAddField-segment"]'
4141
);
42-
testAreaValues([53, 57, 53, 54, 55]);
42+
testAreaValues([11250, 13750, 18750, 16250]);
4343
});
4444

4545
after(() => {

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/bar.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
1717
describe('Vis Builder: Bar Chart', () => {
1818
before(() => {
1919
cy.deleteIndex(VB_INDEX_ID);
20-
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
20+
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
2121
cy.importSavedObjects(VB_PATH_SO_DATA);
2222

2323
cy.visit(VB_APP_URL);
2424

2525
// Wait for page to load
26-
cy.getElementByTestId('homeIcon');
26+
cy.waitForLoader();
2727
cy.vbSelectDataSource(VB_INDEX_PATTERN);
2828

2929
// Set Top nav
@@ -33,13 +33,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
3333
});
3434

3535
it('Basic test', () => {
36-
cy.getElementByTestId('field-age-showDetails').drag(
36+
cy.getElementByTestId('field-salary-showDetails').drag(
3737
'[data-test-subj="dropBoxAddField-metric"]'
3838
);
39-
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
39+
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
4040
'[data-test-subj="dropBoxAddField-segment"]'
4141
);
42-
testBarValues([53, 57, 53, 54, 55]);
42+
testBarValues([11250, 13750, 18750, 16250]);
4343
});
4444

4545
after(() => {

cypress/integration/core-opensearch-dashboards/opensearch-dashboards/apps/vis_builder/vis_types/line.spec.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
1717
describe('Vis Builder: Line Chart', () => {
1818
before(() => {
1919
cy.deleteIndex(VB_INDEX_ID);
20-
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
20+
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
2121
cy.importSavedObjects(VB_PATH_SO_DATA);
2222

2323
cy.visit(VB_APP_URL);
2424

2525
// Wait for page to load
26-
cy.getElementByTestId('homeIcon');
26+
cy.waitForLoader();
2727
cy.vbSelectDataSource(VB_INDEX_PATTERN);
2828

2929
// Set Top nav
@@ -33,13 +33,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
3333
});
3434

3535
it('Basic test', () => {
36-
cy.getElementByTestId('field-age-showDetails').drag(
36+
cy.getElementByTestId('field-salary-showDetails').drag(
3737
'[data-test-subj="dropBoxAddField-metric"]'
3838
);
39-
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
39+
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
4040
'[data-test-subj="dropBoxAddField-segment"]'
4141
);
42-
testLineValues([53, 57, 53, 54, 55]);
42+
testLineValues([11250, 13750, 18750, 16250]);
4343
});
4444

4545
after(() => {

0 commit comments

Comments
 (0)