Alerting: fix flakey default time range assertion (#47262)

This commit is contained in:
Gilles De Mey 2022-04-04 17:35:53 +02:00 committed by GitHub
parent 8428446466
commit 322a14fe6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,12 +93,15 @@ describe('AlertingQueryRunner', () => {
await expect(data.pipe(take(1))).toEmitValuesWith((values) => {
const [data] = values;
// these test are flakey since the absolute computed "timeRange" can differ from the relative "defaultRelativeTimeRange"
// so instead we will check if the size of the timeranges match
const relativeA = rangeUtil.timeRangeToRelative(data.A.timeRange);
const relativeB = rangeUtil.timeRangeToRelative(data.B.timeRange);
const expected = getDefaultRelativeTimeRange();
const defaultRange = getDefaultRelativeTimeRange();
expect(relativeA).toEqual(expected);
expect(relativeB).toEqual(expected);
expect(relativeA.from - defaultRange.from).toEqual(relativeA.to - defaultRange.to);
expect(relativeB.from - defaultRange.from).toEqual(relativeB.to - defaultRange.to);
});
});