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(product-analytics): deflake retention spec week-header assertion (#70316)

Paul D'Ambra68e67ebdc7df
diff --git a/playwright/e2e/product-analytics/retention.spec.ts b/playwright/e2e/product-analytics/retention.spec.ts
index 8aae8e39be04..e803d35c53b9 100644
--- a/playwright/e2e/product-analytics/retention.spec.ts
+++ b/playwright/e2e/product-analytics/retention.spec.ts
@@ -62,8 +62,12 @@ test.describe('Retention', () => {
await test.step('change period from Day to Week', async () => {
await insight.retention.selectPeriod('weeks')
- const headerTexts = await insight.retention.getColumnHeaderTexts()
- expect(headerTexts.filter(isWeekHeader).length).toBe(8)
+ // The period change refetches the query; poll until the weekly headers render
+ // instead of reading the (possibly still daily/loading) table immediately.
+ await expect(async () => {
+ const headerTexts = await insight.retention.getColumnHeaderTexts()
+ expect(headerTexts.filter(isWeekHeader).length).toBe(8)
+ }).toPass({ timeout: 15000 })
})
await test.step('toggle to cumulative retention', async () => {