Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(aio): pin the clock in the backfill timezone test (#127127)

Michael Reichenbachc5e50fae310c
diff --git a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
index 78cdfb3f3e90..f4bed492358c 100644
--- a/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
+++ b/products/ai_observability/frontend/evaluations/evaluationBackfillsLogic.test.ts
@@ -423,16 +423,28 @@ describe('evaluationBackfillsLogic', () => {
})
it('anchors a relative preset on the project timezone', async () => {
- const timezone = 'America/New_York'
- teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, timezone })
- await mountAndSettle()
+ jest.useFakeTimers()
+ try {
+ // New York leaves daylight time on Nov 1, so a 14-day window spans the change.
+ jest.setSystemTime(new Date('2026-11-02T15:00:00Z'))
+ teamLogic.actions.loadCurrentTeamSuccess({ ...MOCK_DEFAULT_TEAM, timezone: 'America/New_York' })
+ mountLogic()
+ await jest.advanceTimersByTimeAsync(ESTIMATE_DEBOUNCE_MS)
+ await expectLogic(logic).toDispatchActions(['loadBackfillsSuccess', 'requestEstimateSuccess'])
+ estimateMock.mockClear()
- logic.actions.setWindowRange('-7d', null)
- await expectLogic(logic).toDispatchActions(['requestEstimateSuccess'])
+ // Not the -7d default, so the request differs from the one the mount already sent.
+ logic.actions.setWindowRange('-14d', null)
+ await jest.advanceTimersByTimeAsync(ESTIMATE_DEBOUNCE_MS)
+ await expectLogic(logic).toDispatchActions(['requestEstimateSuccess'])
- const body = estimateMock.mock.calls[estimateMock.mock.calls.length - 1][2]
- expect(body.window_start).toEqual(dayjs().tz(timezone).startOf('day').subtract(7, 'day').toISOString())
- expect(Math.abs(dayjs(body.window_end).diff(dayjs(), 'second'))).toBeLessThan(5)
+ const body = estimateMock.mock.calls[estimateMock.mock.calls.length - 1][2]
+ // Midnight on Oct 19 is still daylight time (UTC-4), not today's UTC-5.
+ expect(body.window_start).toEqual('2026-10-19T04:00:00.000Z')
+ expect(body.window_end).toEqual(new Date().toISOString())
+ } finally {
+ jest.useRealTimers()
+ }
})
it('polls the list while a backfill is running and stops once none is', async () => {