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): stabilize flaky persons Playwright tests (#64766)

mendral-app[bot]b1bbf0c4c7dd
diff --git a/playwright/e2e/persons/persons.spec.ts b/playwright/e2e/persons/persons.spec.ts
index f14936f7e239..5d8ea2d3754f 100644
--- a/playwright/e2e/persons/persons.spec.ts
+++ b/playwright/e2e/persons/persons.spec.ts
@@ -28,6 +28,7 @@ test.describe('Persons', () => {
const { emailUser } = personsWithIdentity.expected
await test.step('search for the email user and navigate to their detail page', async () => {
+ // goToList now waits for data to load before proceeding
await persons.goToList()
await persons.searchFor(emailUser)
await persons.clickFirstPerson()
@@ -143,8 +144,7 @@ test.describe('Persons', () => {
await test.step('search for the multi-ID person and navigate to their detail page', async () => {
await persons.goToList()
- await persons.searchInput.fill(primaryDistinctId)
- await expect(persons.table.getByRole('link')).toHaveCount(1, { timeout: 15_000 })
+ await persons.searchFor(primaryDistinctId)
await persons.clickFirstPerson()
})
diff --git a/playwright/page-models/personsPage.ts b/playwright/page-models/personsPage.ts
index fdbaef86d1d7..0815eb043af5 100644
--- a/playwright/page-models/personsPage.ts
+++ b/playwright/page-models/personsPage.ts
@@ -37,26 +37,29 @@ export class PersonsPage {
async goToList(): Promise<void> {
await this.page.goto('/persons')
- await expect(this.table).toBeVisible()
+ // Wait for the initial data load to complete (at least one person link visible)
+ await expect(this.table.getByRole('link').first()).toBeVisible()
}
async searchFor(query: string, expectedCount: number = 1): Promise<void> {
await this.searchInput.fill(query)
- await expect(this.table.getByRole('link')).toHaveCount(expectedCount)
+ // Wait for the filtered results with an explicit timeout — the search involves
+ // a debounce + API round-trip that can be slow under CI load.
+ await expect(this.table.getByRole('link')).toHaveCount(expectedCount, { timeout: 30_000 })
}
async clickFirstPerson(): Promise<void> {
const link = this.table.getByRole('link').first()
const href = await link.getAttribute('href')
- await this.page.goto(href!, { waitUntil: 'domcontentloaded' })
- await expect(this.tabs).toBeVisible({ timeout: 15_000 })
+ await this.page.goto(href!, { waitUntil: 'load' })
+ await expect(this.tabs).toBeVisible()
}
async clickNthPerson(n: number = 0): Promise<void> {
const link = this.table.getByRole('link').nth(n)
const href = await link.getAttribute('href')
- await this.page.goto(href!, { waitUntil: 'domcontentloaded' })
- await expect(this.tabs).toBeVisible({ timeout: 15_000 })
+ await this.page.goto(href!, { waitUntil: 'load' })
+ await expect(this.tabs).toBeVisible()
}
async goToPropertiesTab(): Promise<void> {