From 322a14fe6e032146e0b4fed50df3b67714f04b45 Mon Sep 17 00:00:00 2001 From: Gilles De Mey Date: Mon, 4 Apr 2022 17:35:53 +0200 Subject: [PATCH] Alerting: fix flakey default time range assertion (#47262) --- .../alerting/unified/state/AlertingQueryRunner.test.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts b/public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts index 147a506354e..ce5c6580251 100644 --- a/public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts +++ b/public/app/features/alerting/unified/state/AlertingQueryRunner.test.ts @@ -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); }); });