Skip to content

Commit

Permalink
Add test suite
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <[email protected]>
  • Loading branch information
ohltyler committed Jun 26, 2023
1 parent a857b50 commit 8c7c951
Show file tree
Hide file tree
Showing 17 changed files with 587 additions and 504 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
[
{
"value1": 1,
"value2": 10,
"value3": 5
},
{
"value1": 5,
"value2": 1,
"value3": 3
},
{
"value1": 9,
"value2": 6,
"value3": 2
},
{
"value1": 2,
"value2": 1,
"value3": 1
},
{
"value1": 12,
"value2": 5,
"value3": 4
}
]
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[{"count":0,"name":"@timestamp","type":"date","esTypes":["date"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":true},{"count":0,"name":"_id","type":"string","esTypes":["_id"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"_index","type":"string","esTypes":["_index"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"_score","type":"number","scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"_source","type":"_source","esTypes":["_source"],"scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"_type","type":"string","scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"lastname","type":"string","esTypes":["text"],"scripted":false,"searchable":true,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"name","type":"string","esTypes":["text"],"scripted":false,"searchable":true,"aggregatable":false,"readFromDocValues":false}]
[{"count":0,"name":"@timestamp","type":"date","esTypes":["date"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":true},{"count":0,"name":"_id","type":"string","esTypes":["_id"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"_index","type":"string","esTypes":["_index"],"scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"_score","type":"number","scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"_source","type":"_source","esTypes":["_source"],"scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"_type","type":"string","scripted":false,"searchable":false,"aggregatable":false,"readFromDocValues":false},{"count":0,"name":"value1","type":"number","scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"value2","type":"number","scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false},{"count":0,"name":"value3","type":"number","scripted":false,"searchable":true,"aggregatable":true,"readFromDocValues":false}]
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"mappings":{"properties":{"value1":{"type":"integer"},"value2":{"type":"integer"},"value3":{"type":"integer"},"@timestamp":{"type":"date", "format":"epoch_millis"}}},"settings":{"index":{"number_of_shards":"1","number_of_replicas":"1"}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
/*
* Copyright OpenSearch Contributors
* SPDX-License-Identifier: Apache-2.0
*/

import {
INDEX_PATTERN_FILEPATH_SIMPLE,
INDEX_SETTINGS_FILEPATH_SIMPLE,
SAMPLE_DATA_FILEPATH_SIMPLE,
} from '../../../../../utils/constants';
import {
deleteVisAugmenterData,
bootstrapDashboard,
} from '../../../../../utils/dashboards/vis-augmenter/helpers';

describe('Vis augmenter - existing dashboards work as expected', () => {
describe('dashboard with ineligible, eligible, and vega visualizations', () => {
const indexName = 'vis-augmenter-sample-index';
const indexPatternName = 'vis-augmenter-sample-*';
const dashboardName = 'Vis Augmenter Dashboard';
const visualizationSpecs = [
{
name: 'count-agg-vis',
type: 'line',
indexPattern: indexPatternName,
metrics: [],
},
{
name: 'single-metric-vis',
type: 'line',
indexPattern: indexPatternName,
metrics: [
{
aggregation: 'Average',
field: 'value1',
},
],
},
{
name: 'multi-metric-vis',
type: 'line',
indexPattern: indexPatternName,
metrics: [
{
aggregation: 'Average',
field: 'value1',
},
{
aggregation: 'Average',
field: 'value2',
},
{
aggregation: 'Max',
field: 'value3',
},
],
},
{
name: 'area-vis',
type: 'area',
indexPattern: indexPatternName,
metrics: [
{
aggregation: 'Max',
field: 'value2',
},
],
},
{
name: 'vega-vis',
type: 'vega',
indexPattern: indexPatternName,
metrics: [],
},
];

const visualizationNames = visualizationSpecs.map(
(visualizationSpec) => visualizationSpec.name
);

before(() => {
// Create a dashboard and add some visualizations
bootstrapDashboard(
INDEX_SETTINGS_FILEPATH_SIMPLE,
INDEX_PATTERN_FILEPATH_SIMPLE,
SAMPLE_DATA_FILEPATH_SIMPLE,
indexName,
indexPatternName,
dashboardName,
visualizationSpecs
);
});

beforeEach(() => {
cy.visitDashboard(dashboardName);
cy.wait(5000);
});

after(() => {
deleteVisAugmenterData(
indexName,
indexPatternName,
visualizationNames,
dashboardName
);
});

it('All visualizations should be visible', () => {
visualizationNames.forEach((visualizationName) =>
cy.getVisPanelByTitle(visualizationName)
);
});

it('View events option does not exist for any visualization', () => {
visualizationNames.forEach((visualizationName) => {
cy.getVisPanelByTitle(visualizationName)
.openVisContextMenu()
.getMenuItems()
.contains('View Events')
.should('not.exist');
});
});

it('Validate non-vega visualizations are not rendered with vega under the hood', () => {
visualizationSpecs.forEach((visualizationSpec) => {
cy.getVisPanelByTitle(visualizationSpec.name).within(() => {
if (visualizationSpec.type === 'vega') {
cy.get('.vgaVis__view').should('exist');
} else {
cy.get('.vgaVis__view').should('not.exist');
}
});
});
});
});
});

This file was deleted.

2 changes: 1 addition & 1 deletion cypress/utils/dashboards/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import './vis_builder/commands';
import './vis_type_table/commands';
import './feature-anywhere/commands';
import './vis-augmenter/commands';

Cypress.Commands.add('waitForLoader', () => {
const opts = { log: false };
Expand Down
1 change: 1 addition & 0 deletions cypress/utils/dashboards/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ export const SAVED_OBJECTS_PATH =

export * from './vis_builder/constants';
export * from './vis_type_table/constants';
export * from './vis-augmenter/constants';
Loading

0 comments on commit 8c7c951

Please sign in to comment.