Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Vis Builder] Updates tests to visBuilder key #361

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ jobs:
with:
test-name: Core Dashboards using Bundle Snapshot
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'
osd-serve-args: --wizard.enabled=true --data_source.enabled=true
osd-serve-args: --data_source.enabled=true --vis_builder.enabled=true
4 changes: 3 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- [Run Tests](#run-tests)
- [Formatting](#formatting)
- [Onboarding](#onboarding)
- [Test Development](#test-development)
- [Experimental Features](#experimental-features)
- [Release](#release)
- [First Things First](#first-things-first)
- [Ways to Contribute](#ways-to-contribute)
Expand Down Expand Up @@ -172,7 +174,7 @@ Add an environment variable (e.g boolean) to only run tests for the experiementa

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

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.)
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.)

4. Run tests from `opensearch-build`

Expand Down

Large diffs are not rendered by default.

20,000 changes: 20,000 additions & 0 deletions cypress/fixtures/dashboard/opensearch_dashboards/visBuilder/vis-builder.data.txt

Large diffs are not rendered by default.

20,000 changes: 0 additions & 20,000 deletions cypress/fixtures/dashboard/opensearch_dashboards/visBuilder/vis_builder.data.txt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,36 +15,41 @@ import {
VB_METRIC_VIS_TITLE,
VB_PATH_INDEX_DATA,
VB_PATH_SO_DATA,
VB_SO_TYPE,
} from '../../../../../utils/constants';

if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Visualization Builder Base Tests', () => {
before(() => {
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);
});

it('Show existing visualizations in Visualize', () => {
it('Show existing visualizations in Visualize and navigate to it', () => {
cy.visit(`${BASE_PATH}/app/visualize`);
cy.get('input[type="search"]').type(`${VB_METRIC_VIS_TITLE}{enter}`);
cy.get('.euiBasicTable-loading').should('not.exist'); // wait for the loading to stop
cy.getElementByTestId(
`visListingTitleLink-${toTestId(VB_METRIC_VIS_TITLE)}`
).should('exist');
)
.should('exist')
.click();
cy.location('pathname').should('contain', VB_APP_PATH);
});

it('Navigate to Visualization Builder from Visualize', () => {
it('Navigate to Visualization Builder from Create Visualization', () => {
cy.visit(`${BASE_PATH}/app/visualize`);
cy.getElementByTestId('newItemButton').click();
cy.getElementByTestId('visType-wizard').click();
cy.getElementByTestId('visType-vis-builder').click();
cy.location('pathname').should('eq', VB_APP_PATH);
});

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

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);

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

// Update Topnav
cy.setTopNavQuery('age < 50');
cy.setTopNavQuery('salary < 15000');

// See if the value updated
cy.getElementByTestId('visualizationLoader')
.find('.mtrVis__value')
.should('contain.text', `4,390`);
.should('contain.text', `5,000`);
});

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

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);
cy.vbSelectVisType('Metric');

Expand All @@ -85,14 +90,19 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
{
testSubj: 'defaultEditorAggSelect',
type: 'select',
value: 'Average',
value: 'Min',
},
{
testSubj: 'visDefaultEditorField',
type: 'select',
value: 'age',
},
]);

// Check if add worked
cy.getElementByTestId('visualizationLoader')
.find('.mtrVis__value')
.should('contain.text', '54.912');
.should('contain.text', '10');

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

it('Be able to save a visualization', () => {
cy.visit(VB_APP_URL);

// Wait for page to load
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);

// Create basic vis
cy.getElementByTestId('field-undefined-showDetails').drag(
'[data-test-subj=dropBoxAddField-metric]'
);

// Save
const cleanupKey = Date.now();
const title = `VB: vb${cleanupKey}`;
cy.getElementByTestId('visBuilderSaveButton')
.should('not.be.disabled')
.click();
cy.getElementByTestId('savedObjectTitle').type(title + '{enter}');

// Verify save
cy.location('pathname').should('contain', VB_APP_PATH + '/edit');

// Cleanup
cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`);
});

after(() => {
cy.deleteIndex(VB_INDEX_ID);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,49 @@ import {
VB_INDEX_PATTERN,
VB_INDEX_ID,
VB_DASHBOARD_ID,
VB_METRIC_EMBEDDABLE_ID,
VB_BAR_EMBEDDABLE_ID,
toTestId,
VB_INDEX_DOC_COUNT,
VB_INDEX_START_TIME,
VB_INDEX_END_TIME,
VB_PATH_INDEX_DATA,
VB_PATH_SO_DATA,
VB_LINE_VIS_TITLE,
VB_SO_TYPE,
VB_METRIC_VIS_TITLE,
VB_BAR_VIS_TITLE,
} from '../../../../../utils/constants';

if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Visualization Builder Dashboard Tests', () => {
before(() => {
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);

cy.importSavedObjects(VB_PATH_SO_DATA);

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

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();

cy.setTopNavDate(VB_INDEX_START_TIME, VB_INDEX_END_TIME);
});

it('Should have valid visualizations', () => {
cy.get(`[data-test-embeddable-id="${VB_METRIC_EMBEDDABLE_ID}"]`)
cy.getElementByTestId(
`embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}`
)
.should('contain.text', VB_METRIC_VIS_TITLE)
.siblings('.embPanel__content')
.find('.mtrVis__value')
.should('contain.text', VB_INDEX_DOC_COUNT); // Total no of record in the sample daa
cy.get(`[data-test-embeddable-id="${VB_BAR_EMBEDDABLE_ID}"]`)
cy.getElementByTestId(
`embeddablePanelHeading-${toTestId(VB_BAR_VIS_TITLE, '')}`
)
.should('contain.text', VB_BAR_VIS_TITLE)
.siblings('.embPanel__content')
.find('.visLegend__valueTitle')
.should('contain.text', `Count`);
.should('contain.text', `Median`);
});

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

// Create a metric visualisation
cy.vbSelectDataSource(VB_INDEX_PATTERN);
Expand All @@ -79,7 +88,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
// Save and return
const cleanupKey = Date.now();
const visTitle = `VB: New Dashboard Visualization - vb${cleanupKey}`;
cy.getElementByTestId('wizardSaveButton')
cy.getElementByTestId('visBuilderSaveButton')
.should('not.be.disabled')
.click();
cy.getElementByTestId('savedObjectTitle').type(visTitle);
Expand All @@ -93,13 +102,15 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
// Cleanup
cy.getElementByTestId('dashboardViewOnlyMode').click();
cy.getElementByTestId('confirmModalConfirmButton').click();
cy.deleteSavedObjectByType('wizard', `vb${cleanupKey}`);
cy.deleteSavedObjectByType(VB_SO_TYPE, `vb${cleanupKey}`);
});

it('Should be able to edit a visualization', () => {
// Navigate to vis builder
cy.getElementByTestId('dashboardEditMode').click();
cy.get(`[data-test-embeddable-id="${VB_METRIC_EMBEDDABLE_ID}"]`)
cy.getElementByTestId(
`embeddablePanelHeading-${toTestId(VB_METRIC_VIS_TITLE, '')}`
)
.find('[data-test-subj="embeddablePanelToggleMenuIcon"]')
.click();
cy.getElementByTestId('embeddablePanelAction-editPanel').click();
Expand All @@ -119,7 +130,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
]);

// Save and return
cy.getElementByTestId('wizardsaveAndReturnButton').click();
cy.getElementByTestId('visBuilderSaveAndReturnButton').click();

cy.getElementByTestId('visualizationLoader').should(
'contain.text',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (Cypress.env('VISBUILDER_ENABLED')) {

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

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

// Check Dashboard
cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`);
cy.getElementByTestId('wizardLoader').should('exist');
cy.getElementByTestId('visBuilderLoader').should('exist');
});

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

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

// Check Dashboard
cy.visit(`${BASE_PATH}/app/dashboards#/view/${VB_DASHBOARD_ID}`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Line Chart', () => {
before(() => {
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);

cy.visit(VB_APP_URL);

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);

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

it('Basic test', () => {
cy.getElementByTestId('field-age-showDetails').drag(
cy.getElementByTestId('field-salary-showDetails').drag(
'[data-test-subj="dropBoxAddField-metric"]'
);
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
'[data-test-subj="dropBoxAddField-segment"]'
);
testAreaValues([53, 57, 53, 54, 55]);
testAreaValues([11250, 13750, 18750, 16250]);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Bar Chart', () => {
before(() => {
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);

cy.visit(VB_APP_URL);

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);

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

it('Basic test', () => {
cy.getElementByTestId('field-age-showDetails').drag(
cy.getElementByTestId('field-salary-showDetails').drag(
'[data-test-subj="dropBoxAddField-metric"]'
);
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
'[data-test-subj="dropBoxAddField-segment"]'
);
testBarValues([53, 57, 53, 54, 55]);
testBarValues([11250, 13750, 18750, 16250]);
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ if (Cypress.env('VISBUILDER_ENABLED')) {
describe('Vis Builder: Line Chart', () => {
before(() => {
cy.deleteIndex(VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA, VB_INDEX_ID);
cy.bulkUploadDocs(VB_PATH_INDEX_DATA);
cy.importSavedObjects(VB_PATH_SO_DATA);

cy.visit(VB_APP_URL);

// Wait for page to load
cy.getElementByTestId('homeIcon');
cy.waitForLoader();
cy.vbSelectDataSource(VB_INDEX_PATTERN);

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

it('Basic test', () => {
cy.getElementByTestId('field-age-showDetails').drag(
cy.getElementByTestId('field-salary-showDetails').drag(
'[data-test-subj="dropBoxAddField-metric"]'
);
cy.getElementByTestId('field-genre.keyword-showDetails').drag(
cy.getElementByTestId('field-categories.keyword-showDetails').drag(
'[data-test-subj="dropBoxAddField-segment"]'
);
testLineValues([53, 57, 53, 54, 55]);
testLineValues([11250, 13750, 18750, 16250]);
});

after(() => {
Expand Down
Loading