-
Notifications
You must be signed in to change notification settings - Fork 113
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Vis Augmenter / Feature Anywhere] Add test suite for vanilla OSD + h…
…elper fns for plugins (#725) * feature anywhere initial tests Signed-off-by: Jovan Cvetkovic <[email protected]> * Add test suite Signed-off-by: Tyler Ohlsen <[email protected]> * Remove unnecessary test case Signed-off-by: Tyler Ohlsen <[email protected]> * Optimize getters Signed-off-by: Tyler Ohlsen <[email protected]> --------- Signed-off-by: Jovan Cvetkovic <[email protected]> Signed-off-by: Tyler Ohlsen <[email protected]> Co-authored-by: Jovan Cvetkovic <[email protected]>
- Loading branch information
1 parent
6823c82
commit d65bf9f
Showing
11 changed files
with
581 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
cypress/fixtures/dashboard/opensearch_dashboards/vis-augmenter/sample-data-simple/data.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
] |
1 change: 1 addition & 0 deletions
1
...dashboard/opensearch_dashboards/vis-augmenter/sample-data-simple/index-pattern-fields.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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":"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}] |
1 change: 1 addition & 0 deletions
1
...tures/dashboard/opensearch_dashboards/vis-augmenter/sample-data-simple/index-settings.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"}}} |
130 changes: 130 additions & 0 deletions
130
...ion/core-opensearch-dashboards/opensearch-dashboards/apps/vis-augmenter/dashboard_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
/* | ||
* 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('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 contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import _ from 'lodash'; | ||
import { BASE_PATH } from '../../constants'; | ||
|
||
Cypress.Commands.add('getVisPanelByTitle', (title) => | ||
cy.get(`[data-title="${title}"]`).parents('.embPanel').should('be.visible') | ||
); | ||
|
||
Cypress.Commands.add('openVisContextMenu', { prevSubject: true }, (panel) => | ||
cy | ||
.wrap(panel) | ||
.find(`[data-test-subj="embeddablePanelContextMenuClosed"]`) | ||
.click() | ||
.then(() => cy.get('.euiContextMenu')) | ||
); | ||
|
||
Cypress.Commands.add( | ||
'clickVisPanelMenuItem', | ||
{ prevSubject: 'optional' }, | ||
(menu, text) => | ||
(menu ? cy.wrap(menu) : cy.get('.euiContextMenu')) | ||
.find('button') | ||
.contains(text) | ||
.click() | ||
.then(() => cy.get('.euiContextMenu')) | ||
); | ||
|
||
Cypress.Commands.add('getMenuItems', { prevSubject: 'optional' }, (menu) => | ||
(menu ? cy.wrap(menu) : cy.get('.euiContextMenu')).find('button') | ||
); | ||
|
||
Cypress.Commands.add('visitDashboard', (dashboardName) => { | ||
cy.visit(`${BASE_PATH}/app/dashboards`); | ||
cy.get('.euiFieldSearch').type(dashboardName); | ||
cy.wait(1000); | ||
cy.get('[data-test-subj="itemsInMemTable"]').contains(dashboardName).click({ | ||
force: true, | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
const SAMPLE_DATA_DIR_SIMPLE = | ||
'dashboard/opensearch_dashboards/vis-augmenter/sample-data-simple/'; | ||
|
||
export const SAMPLE_DATA_FILEPATH_SIMPLE = SAMPLE_DATA_DIR_SIMPLE + 'data.json'; | ||
|
||
export const INDEX_PATTERN_FILEPATH_SIMPLE = | ||
SAMPLE_DATA_DIR_SIMPLE + 'index-pattern-fields.txt'; | ||
|
||
export const INDEX_SETTINGS_FILEPATH_SIMPLE = | ||
SAMPLE_DATA_DIR_SIMPLE + 'index-settings.txt'; |
Oops, something went wrong.