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(e2e): resolve flaky auth redirect test by using waitUntil: commit (#63548)

mendral-app[bot]03e21e8d3607
diff --git a/playwright/e2e/auth.spec.ts b/playwright/e2e/auth.spec.ts
index 9a35a11859cc..970919970ab4 100644
--- a/playwright/e2e/auth.spec.ts
+++ b/playwright/e2e/auth.spec.ts
@@ -88,7 +88,7 @@ test.describe('Auth', () => {
test('Redirect to appropriate place after login', async ({ page, context }) => {
await context.clearCookies()
- await page.goto('/activity/explore')
+ await page.goto('/activity/explore', { waitUntil: 'commit' })
await expect(page).toHaveURL(/\/login/)
await loginPage.enterUsername(LOGIN_USERNAME)
@@ -103,7 +103,7 @@ test.describe('Auth', () => {
test('Redirect to appropriate place after login with complex URL', async ({ page, context }) => {
await context.clearCookies()
- await page.goto('/insights?search=testString')
+ await page.goto('/insights?search=testString', { waitUntil: 'commit' })
await expect(page).toHaveURL(/\/login/)
await loginPage.enterUsername(LOGIN_USERNAME)
@@ -125,6 +125,7 @@ test.describe('Auth', () => {
test('Logout in another tab results in logout in the current tab too', async ({ page, context }) => {
const secondPage = await context.newPage()
await secondPage.goto('/')
+ await secondPage.locator('[data-attr=new-account-menu-button]').waitFor({ state: 'visible', timeout: 30000 })
await secondPage.locator('[data-attr=new-account-menu-button]').click()
await secondPage.locator('[data-attr=new-account-menu-logout-button]').click()
await secondPage.waitForURL(/\/login/)