From 826eb83257a854df676d25ba71a7dfe826d0e4e5 Mon Sep 17 00:00:00 2001 From: "grafana-delivery-bot[bot]" <132647405+grafana-delivery-bot[bot]@users.noreply.github.com> Date: Thu, 13 Nov 2025 13:48:40 +0000 Subject: [PATCH] [release-12.3.1] Playwright: fix timezone test to work at all times (#113841) Playwright: fix timezone test to work at all times (#113827) * fix timezone test to work at all times * remove unused imports (cherry picked from commit f5f0c1e6f6f3c4099a70d9bbf47378180809be9f) Co-authored-by: Ashley Harrison --- .../dashboards-suite/dashboard-time-zone.spec.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/e2e-playwright/dashboards-suite/dashboard-time-zone.spec.ts b/e2e-playwright/dashboards-suite/dashboard-time-zone.spec.ts index 271e2f42b1f..56e3814b8d2 100644 --- a/e2e-playwright/dashboards-suite/dashboard-time-zone.spec.ts +++ b/e2e-playwright/dashboards-suite/dashboard-time-zone.spec.ts @@ -1,4 +1,4 @@ -import { addDays, addHours, differenceInCalendarDays, differenceInMinutes, isBefore, parseISO, toDate } from 'date-fns'; +import { differenceInMinutes, parseISO, toDate } from 'date-fns'; import { Page } from 'playwright-core'; import { test, expect, DashboardPage, E2ESelectorGroups } from '@grafana/plugin-e2e'; @@ -266,10 +266,7 @@ const isTimeCorrect = (inUtc: string, inTz: string, offset: number): boolean => } const utcDate = toDate(parseISO(inUtc)); - const utcDateWithOffset = addHours(toDate(parseISO(inUtc)), offset); - const dayDifference = differenceInCalendarDays(utcDate, utcDateWithOffset); // if the utcDate +/- offset is the day before/after then we need to adjust reference - const dayOffset = isBefore(utcDateWithOffset, utcDate) ? dayDifference * -1 : dayDifference; - const tzDate = addDays(toDate(parseISO(inTz)), dayOffset); // adjust tzDate with any dayOffset + const tzDate = toDate(parseISO(inTz)); const diff = Math.abs(differenceInMinutes(utcDate, tzDate)); // use Math.abs if tzDate is in future return diff <= Math.abs(offset * 60);