-
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.
[Feature Anywhere / Vis Augmenter] Add test flows for integration wit…
…h AD plugin (#727) * feature anywhere initial tests Signed-off-by: Jovan Cvetkovic <[email protected]> * Add test suite Signed-off-by: Tyler Ohlsen <[email protected]> * Add AD vis augmenter tests Signed-off-by: Tyler Ohlsen <[email protected]> * More refactoring Signed-off-by: Tyler Ohlsen <[email protected]> * More tests Signed-off-by: Tyler Ohlsen <[email protected]> * Add test for AD cleanup scenario Signed-off-by: Tyler Ohlsen <[email protected]> * Set up saved obj test suite Signed-off-by: Tyler Ohlsen <[email protected]> * Add reminder TODO Signed-off-by: Tyler Ohlsen <[email protected]> * Add tests regarding saved obj visibility Signed-off-by: Tyler Ohlsen <[email protected]> * Add view events tests Signed-off-by: Tyler Ohlsen <[email protected]> * cleanup Signed-off-by: Tyler Ohlsen <[email protected]> * remove import 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
d65bf9f
commit 5013760
Showing
8 changed files
with
509 additions
and
23 deletions.
There are no files selected for viewing
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
145 changes: 145 additions & 0 deletions
145
...tion/plugins/anomaly-detection-dashboards-plugin/vis_augmenter/associate_detector_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,145 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { | ||
deleteVisAugmenterData, | ||
bootstrapDashboard, | ||
openAddAnomalyDetectorFlyout, | ||
openAssociatedDetectorsFlyout, | ||
createDetectorFromVis, | ||
associateDetectorFromVis, | ||
unlinkDetectorFromVis, | ||
ensureDetectorIsLinked, | ||
ensureDetectorDetails, | ||
openDetectorDetailsPageFromFlyout, | ||
} from '../../../../utils/helpers'; | ||
import { | ||
INDEX_PATTERN_FILEPATH_SIMPLE, | ||
INDEX_SETTINGS_FILEPATH_SIMPLE, | ||
SAMPLE_DATA_FILEPATH_SIMPLE, | ||
} from '../../../../utils/constants'; | ||
|
||
describe('Anomaly detection integration with vis augmenter', () => { | ||
const indexName = 'ad-vis-augmenter-sample-index'; | ||
const indexPatternName = 'ad-vis-augmenter-sample-*'; | ||
const dashboardName = 'AD Vis Augmenter Dashboard'; | ||
const detectorName = 'ad-vis-augmenter-detector'; | ||
const visualizationName = 'single-metric-vis'; | ||
const visualizationSpec = { | ||
name: visualizationName, | ||
type: 'line', | ||
indexPattern: indexPatternName, | ||
metrics: [ | ||
{ | ||
aggregation: 'Average', | ||
field: 'value1', | ||
}, | ||
], | ||
}; | ||
|
||
before(() => { | ||
// Create a dashboard and add some visualizations | ||
cy.wait(5000); | ||
bootstrapDashboard( | ||
INDEX_SETTINGS_FILEPATH_SIMPLE, | ||
INDEX_PATTERN_FILEPATH_SIMPLE, | ||
SAMPLE_DATA_FILEPATH_SIMPLE, | ||
indexName, | ||
indexPatternName, | ||
dashboardName, | ||
[visualizationSpec] | ||
); | ||
}); | ||
|
||
after(() => { | ||
deleteVisAugmenterData( | ||
indexName, | ||
indexPatternName, | ||
[visualizationName], | ||
dashboardName | ||
); | ||
cy.deleteADSystemIndices(); | ||
}); | ||
|
||
beforeEach(() => {}); | ||
|
||
afterEach(() => {}); | ||
|
||
it('Shows empty state when no associated detectors', () => { | ||
openAssociatedDetectorsFlyout(dashboardName, visualizationName); | ||
cy.getElementByTestId('emptyAssociatedDetectorFlyoutMessage'); | ||
}); | ||
|
||
it('Create new detector from visualization', () => { | ||
openAddAnomalyDetectorFlyout(dashboardName, visualizationName); | ||
createDetectorFromVis(detectorName); | ||
|
||
ensureDetectorIsLinked(dashboardName, visualizationName, detectorName); | ||
|
||
// Since this detector is created based off of vis metrics, we assume here | ||
// the number of features will equal the number of metrics we have specified. | ||
ensureDetectorDetails(detectorName, visualizationSpec.metrics.length); | ||
|
||
unlinkDetectorFromVis(dashboardName, visualizationName, detectorName); | ||
}); | ||
|
||
it('Associate existing detector - creation flow', () => { | ||
openAddAnomalyDetectorFlyout(dashboardName, visualizationName); | ||
|
||
cy.get('.euiFlyout').find('.euiTitle').contains('Add anomaly detector'); | ||
// ensuring the flyout is defaulting to detector creation vs. association | ||
cy.getElementByTestId('adAnywhereCreateDetectorButton'); | ||
cy.get('[id="add-anomaly-detector__existing"]').click(); | ||
|
||
associateDetectorFromVis(detectorName); | ||
|
||
ensureDetectorIsLinked(dashboardName, visualizationName, detectorName); | ||
unlinkDetectorFromVis(dashboardName, visualizationName, detectorName); | ||
}); | ||
|
||
it('Associate existing detector - associated detectors flow', () => { | ||
openAssociatedDetectorsFlyout(dashboardName, visualizationName); | ||
cy.getElementByTestId('associateDetectorButton').click(); | ||
associateDetectorFromVis(detectorName); | ||
|
||
ensureDetectorIsLinked(dashboardName, visualizationName, detectorName); | ||
unlinkDetectorFromVis(dashboardName, visualizationName, detectorName); | ||
}); | ||
|
||
it('Deleting linked detector shows error once and removes from associated detectors list', () => { | ||
openAssociatedDetectorsFlyout(dashboardName, visualizationName); | ||
cy.getElementByTestId('associateDetectorButton').click(); | ||
associateDetectorFromVis(detectorName); | ||
ensureDetectorIsLinked(dashboardName, visualizationName, detectorName); | ||
openDetectorDetailsPageFromFlyout(); | ||
cy.getElementByTestId('configurationsTab').click(); | ||
cy.getElementByTestId('detectorNameHeader').within(() => { | ||
cy.contains(detectorName); | ||
}); | ||
|
||
cy.getElementByTestId('actionsButton').click(); | ||
cy.getElementByTestId('deleteDetectorItem').click(); | ||
cy.getElementByTestId('typeDeleteField').type('delete', { force: true }); | ||
cy.getElementByTestId('confirmButton').click(); | ||
cy.wait(5000); | ||
|
||
cy.visitDashboard(dashboardName); | ||
|
||
// Expect an error message to show up | ||
cy.getElementByTestId('errorToastMessage').parent().find('button').click(); | ||
cy.get('.euiModal'); | ||
cy.get('.euiModalFooter').find('button').click(); | ||
cy.wait(2000); | ||
|
||
// Expect associated detector list to be empty (the association should be removed) | ||
openAssociatedDetectorsFlyout(dashboardName, visualizationName); | ||
cy.getElementByTestId('emptyAssociatedDetectorFlyoutMessage'); | ||
cy.wait(2000); | ||
|
||
// Reload the dashboard - error toast shouldn't show anymore | ||
cy.visitDashboard(dashboardName); | ||
cy.getElementByTestId('errorToastMessage').should('not.exist'); | ||
}); | ||
}); |
119 changes: 119 additions & 0 deletions
119
...lugins/anomaly-detection-dashboards-plugin/vis_augmenter/augment_vis_saved_object_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,119 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import { CommonUI } from '@opensearch-dashboards-test/opensearch-dashboards-test-library'; | ||
import { | ||
deleteVisAugmenterData, | ||
bootstrapDashboard, | ||
openAddAnomalyDetectorFlyout, | ||
createDetectorFromVis, | ||
unlinkDetectorFromVis, | ||
ensureDetectorIsLinked, | ||
filterByObjectType, | ||
} from '../../../../utils/helpers'; | ||
import { | ||
INDEX_PATTERN_FILEPATH_SIMPLE, | ||
INDEX_SETTINGS_FILEPATH_SIMPLE, | ||
SAMPLE_DATA_FILEPATH_SIMPLE, | ||
} from '../../../../utils/constants'; | ||
|
||
describe('AD augment-vis saved objects', () => { | ||
const commonUI = new CommonUI(cy); | ||
const indexName = 'ad-vis-augmenter-sample-index'; | ||
const indexPatternName = 'ad-vis-augmenter-sample-*'; | ||
const dashboardName = 'AD Vis Augmenter Dashboard'; | ||
const detectorName = 'ad-vis-augmenter-detector'; | ||
const visualizationName = 'single-metric-vis'; | ||
const visualizationSpec = { | ||
name: visualizationName, | ||
type: 'line', | ||
indexPattern: indexPatternName, | ||
metrics: [ | ||
{ | ||
aggregation: 'Average', | ||
field: 'value1', | ||
}, | ||
], | ||
}; | ||
|
||
before(() => { | ||
// Create a dashboard and add some visualizations | ||
cy.wait(5000); | ||
bootstrapDashboard( | ||
INDEX_SETTINGS_FILEPATH_SIMPLE, | ||
INDEX_PATTERN_FILEPATH_SIMPLE, | ||
SAMPLE_DATA_FILEPATH_SIMPLE, | ||
indexName, | ||
indexPatternName, | ||
dashboardName, | ||
[visualizationSpec] | ||
); | ||
}); | ||
|
||
after(() => { | ||
deleteVisAugmenterData( | ||
indexName, | ||
indexPatternName, | ||
[visualizationName], | ||
dashboardName | ||
); | ||
cy.deleteADSystemIndices(); | ||
}); | ||
|
||
beforeEach(() => {}); | ||
|
||
afterEach(() => {}); | ||
|
||
it('Associating a detector creates a visible saved object', () => { | ||
openAddAnomalyDetectorFlyout(dashboardName, visualizationName); | ||
createDetectorFromVis(detectorName); | ||
ensureDetectorIsLinked(dashboardName, visualizationName, detectorName); | ||
|
||
cy.visitSavedObjectsManagement(); | ||
filterByObjectType('augment-vis'); | ||
cy.getElementByTestId('savedObjectsTable') | ||
.find('.euiTableRow') | ||
.should('have.length', 1); | ||
}); | ||
|
||
it('Created AD saved object has correct fields', () => { | ||
cy.visitSavedObjectsManagement(); | ||
filterByObjectType('augment-vis'); | ||
cy.getElementByTestId('savedObjectsTableAction-inspect').click(); | ||
cy.contains('originPlugin'); | ||
commonUI.checkElementExists('[value="anomalyDetectionDashboards"]', 1); | ||
cy.contains('pluginResource.type'); | ||
commonUI.checkElementExists('[value="Anomaly Detectors"]', 1); | ||
cy.contains('pluginResource.id'); | ||
cy.contains('visLayerExpressionFn.type'); | ||
commonUI.checkElementExists('[value="PointInTimeEvents"]', 1); | ||
cy.contains('visLayerExpressionFn.name'); | ||
commonUI.checkElementExists('[value="overlay_anomalies"]', 1); | ||
}); | ||
|
||
it('Removing an association deletes the saved object', () => { | ||
unlinkDetectorFromVis(dashboardName, visualizationName, detectorName); | ||
|
||
cy.visitSavedObjectsManagement(); | ||
filterByObjectType('augment-vis'); | ||
cy.getElementByTestId('savedObjectsTable') | ||
.find('.euiTableRow') | ||
.contains('No items found'); | ||
}); | ||
|
||
it('Deleting the visualization from the edit view deletes the saved object', () => { | ||
cy.visitSavedObjectsManagement(); | ||
filterByObjectType('visualization'); | ||
cy.getElementByTestId('savedObjectsTableAction-inspect').click(); | ||
cy.getElementByTestId('savedObjectEditDelete').click(); | ||
cy.getElementByTestId('confirmModalConfirmButton').click(); | ||
cy.wait(3000); | ||
|
||
filterByObjectType('augment-vis'); | ||
cy.getElementByTestId('savedObjectsTable') | ||
.find('.euiTableRow') | ||
.contains('No items found'); | ||
}); | ||
}); |
Oops, something went wrong.