Skip to content

Commit

Permalink
WIP 3_panels_spec - visualization scripted setup
Browse files Browse the repository at this point in the history
Signed-off-by: Peter Fitzgibbons <[email protected]>
  • Loading branch information
pjfitzgibbons committed Jun 5, 2023
1 parent 8fa2e30 commit 5072a57
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
13 changes: 9 additions & 4 deletions .cypress/integration/3_panels.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
delay,
NEW_VISUALIZATION_NAME,
PPL_FILTER,
PPL_VISUALIZATION_CONFIGS,
PPL_VISUALIZATIONS,
PPL_VISUALIZATIONS_NAMES,
TEST_PANEL,
Expand Down Expand Up @@ -337,7 +338,11 @@ describe('Panels testing with Sample Data', () => {
console.log('Add PPL Test');
createSavedObjectPanel().as('thePanel');

createVisualization(PPL_VISUALIZATIONS_NAMES[2], PPL_VISUALIZATIONS[2]).as('vis1');
createVisualization(
PPL_VISUALIZATIONS_NAMES[2],
PPL_VISUALIZATIONS[2],
PPL_VISUALIZATION_CONFIGS[2]
).as('vis1');

cy.then(function () {
addVisualizationsToPanel(this.thePanel, [this.vis1.id]);
Expand All @@ -354,6 +359,7 @@ describe('Panels testing with Sample Data', () => {
cy.get('[data-test-subj="superDatePickerQuickMenu"')
.first()
.within(() => {
cy.get('input[aria-label="Time value"]').type('2', { force: true });
cy.get('select[aria-label="Time unit"]').select('years');
cy.get('button').contains('Apply').click();
});
Expand Down Expand Up @@ -726,7 +732,7 @@ const addVisualizationsToPanel = (panel, additionalVisualizationIds: string[]) =
});
};

const createVisualization = (newName, query) => {
const createVisualization = (newName, query, vizConfig) => {
return cy
.request({
method: 'POST',
Expand Down Expand Up @@ -760,8 +766,7 @@ const createVisualization = (newName, query) => {
name: newName,
description: '',
type: 'bar',
user_configs:
'{"dataConfig":{"dimensions":[{"label":"Carrier","name":"Carrier"}],"series":[{"customLabel":"","label":"Cancelled","name":"Cancelled","aggregation":"count"}],"breakdowns":[]}}',
user_configs: vizConfig,
sub_type: 'visualization',
},
},
Expand Down
10 changes: 8 additions & 2 deletions .cypress/utils/panel_constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ export const SAMPLE_VISUALIZATIONS_NAMES = [
];

export const PPL_VISUALIZATIONS = [
'source = opensearch_dashboards_sample_data_flights | stats count() by Dest',
'source = opensearch_dashboards_sample_data_flights | stats count(Dest) by Dest',
'source = opensearch_dashboards_sample_data_flights | stats avg(FlightDelayMin) by Carrier',
'source = opensearch_dashboards_sample_data_flights | stats max( DistanceKilometers ) by DestCityName',
'source = opensearch_dashboards_sample_data_flights | stats max( DistanceKilometers ) by Dest',
];

export const PPL_VISUALIZATIONS_NAMES = [
Expand All @@ -31,6 +31,12 @@ export const PPL_VISUALIZATIONS_NAMES = [
'Max distance by destination city',
];

export const PPL_VISUALIZATION_CONFIGS = [
'{"dataConfig":{"series":[{"customLabel":"","label":"Dest","name":"Dest","aggregation":"count"}],"dimensions":[{"label":"Dest","name":"Dest"}],"breakdowns":[]}}',
'{"dataConfig":{"series":[{"customLabel":"","label":"FlightDelayMin","name":"FlightDelayMin","aggregation":"avg"}],"dimensions":[{"label":"Dest","name":"Dest"}],"breakdowns":[]}}',
'{"dataConfig":{"series":[{"label":"DistanceKilometers","name":"DistanceKilometers","aggregation":"max","customLabel":""}],"dimensions":[{"label":"Dest","name":"Dest"}]}}',
];

export const NEW_VISUALIZATION_NAME = 'Flight count by destination airport';

export const PPL_FILTER = "where Carrier = 'OpenSearch-Air' | where Dest = 'Munich Airport'";

0 comments on commit 5072a57

Please sign in to comment.