Skip to content

Commit

Permalink
Add more historical analysis tests
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Ohlsen <ohltyler@amazon.com>
  • Loading branch information
ohltyler committed Feb 28, 2022
1 parent 763b77a commit d3bf70e
Showing 1 changed file with 40 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,25 @@ context('Historical results page', () => {
);
}

function verifyNoAnomaliesInCharts() {
// Wait for any kicked off historical analysis to finish. Relying on default
// timeout (60s) to find an element that only shows up when the analysis is finished
cy.getElementByTestId('detectorStateFinished').should('exist');

// Let results load separately, since they load asynchronously. Should take <1s
cy.wait(5000);

cy.getElementByTestId('anomalyOccurrenceStat').within(() => {
cy.get('.euiTitle--small')
.invoke('text')
.then((anomalyOccurrenceCount) => {
cy.log('Num anomaly occurrences: ' + anomalyOccurrenceCount);
expect(parseInt(anomalyOccurrenceCount)).to.equal(0);
});
});
cy.getElementByTestId('anomalyOccurrencesHeader').should('contain', '(0)');
}

// Creating a sample detector and visiting the config page
before(() => {
cy.server();
Expand Down Expand Up @@ -82,6 +101,27 @@ context('Historical results page', () => {
verifyAnomaliesInCharts();
});

it('Filtering by date range', () => {
cy.getElementByTestId('superDatePickerToggleQuickMenuButton').click();
cy.get(`[aria-label="Next time window"]`).click();
cy.contains('Refresh').click();
verifyNoAnomaliesInCharts();

cy.getElementByTestId('superDatePickerToggleQuickMenuButton').click();
cy.get(`[aria-label="Previous time window"]`).click();
cy.contains('Refresh').click();
verifyAnomaliesInCharts();
});

it('Aggregations render anomalies', () => {
cy.get(`[aria-label="Daily max"]`).click();
verifyAnomaliesInCharts();
cy.get(`[aria-label="Weekly max"]`).click();
verifyAnomaliesInCharts();
cy.get(`[aria-label="Monthly max"]`).click();
verifyAnomaliesInCharts();
});

it('Run subsequent historical analysis', () => {
cy.getElementByTestId('modifyHistoricalAnalysisButton').click();
cy.getElementByTestId('historicalAnalysisModalHeader').should('exist');
Expand Down

0 comments on commit d3bf70e

Please sign in to comment.