[ML] Fix bucket span initialisation on the Anomaly Explorer page (#133366)

* fix filter condition

* add functional tests for browser refresh

* waitForSwimLanesToLoad
This commit is contained in:
Dima Arnautov 2022-06-03 18:24:07 +02:00 committed by GitHub
parent e2336ff312
commit 91925d974a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View file

@ -732,7 +732,7 @@ export class AnomalyTimelineStateService extends StateService {
public getSwimLaneBucketInterval$(): Observable<TimeBucketsInterval> {
return this._swimLaneBucketInterval$.pipe(
filter((v): v is TimeBucketsInterval => !v),
filter((v): v is TimeBucketsInterval => !!v),
distinctUntilChanged((prev, curr) => {
return prev.asSeconds() === curr.asSeconds();
})

View file

@ -62,6 +62,7 @@ export default function ({ getService }: FtrProviderContext) {
const esArchiver = getService('esArchiver');
const ml = getService('ml');
const elasticChart = getService('elasticChart');
const browser = getService('browser');
describe('anomaly explorer', function () {
this.tags(['ml']);
@ -213,6 +214,19 @@ export default function ({ getService }: FtrProviderContext) {
'selectedLanes%3A!(Overall)%2CselectedTimes%3A!(1454846400%2C1454860800)%2CselectedType%3Aoverall%2CshowTopFieldValues%3A!t'
);
await ml.testExecution.logTestStep('restores app state from the URL state');
await browser.refresh();
await elasticChart.setNewChartUiDebugFlag(true);
await ml.swimLane.waitForSwimLanesToLoad();
await ml.swimLane.assertSelection(overallSwimLaneTestSubj, {
x: [1454846400000, 1454860800000],
y: ['Overall'],
});
await ml.swimLane.assertAxisLabels(viewBySwimLaneTestSubj, 'y', ['EGF', 'DAL']);
await ml.anomalyExplorer.assertAnomalyExplorerChartsCount(5);
await ml.anomalyExplorer.assertInfluencerFieldListLength('airline', 2);
await ml.anomaliesTable.assertTableRowsCount(4);
await ml.testExecution.logTestStep('clears the selection');
await ml.anomalyExplorer.clearSwimLaneSelection();
await ml.swimLane.waitForSwimLanesToLoad();
@ -274,6 +288,22 @@ export default function ({ getService }: FtrProviderContext) {
y: ['Overall'],
});
await ml.testExecution.logTestStep('restores app state from the URL state');
await browser.refresh();
await elasticChart.setNewChartUiDebugFlag(true);
await ml.swimLane.waitForSwimLanesToLoad();
await ml.swimLane.assertSelection(viewBySwimLaneTestSubj, {
x: [1454817600000, 1454832000000],
y: ['AAL'],
});
await ml.anomaliesTable.assertTableRowsCount(1);
await ml.anomalyExplorer.assertInfluencerFieldListLength('airline', 1);
await ml.anomalyExplorer.assertAnomalyExplorerChartsCount(1);
await ml.swimLane.assertSelection(overallSwimLaneTestSubj, {
x: [1454817600000, 1454832000000],
y: ['Overall'],
});
await ml.testExecution.logTestStep('clears the selection');
await ml.anomalyExplorer.clearSwimLaneSelection();
await ml.swimLane.waitForSwimLanesToLoad();