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.

chore(customer-analytics): pin the mocked clock in the summaries deadline test (#88754)

Georges-Antoine Assi3752890714dc
diff --git a/products/customer_analytics/frontend/components/Accounts/accountSummariesLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountSummariesLogic.test.ts
index 07e1870c66b5..63d559ae8dd2 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountSummariesLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountSummariesLogic.test.ts
@@ -174,8 +174,10 @@ describe('accountSummariesLogic', () => {
mockList.mockResolvedValue({ count: 0, next: null, previous: null, results: [] })
mockPatch.mockResolvedValue(CADENCE_OFF)
await mount('acc-deadline')
+ // Pin the clock before setCadence: the deadline is written with Date.now() inside the
+ // listener, and any real-clock drift past startedAt would put the mocked "now" below it.
const startedAt = Date.now()
- const nowSpy = jest.spyOn(Date, 'now')
+ const nowSpy = jest.spyOn(Date, 'now').mockReturnValue(startedAt)
logic.actions.setCadence('daily')
await expectLogic(logic).toFinishAllListeners()