: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(e2e): stabilize flaky persons and cohort Playwright tests (#63531)
mendral-app[bot]a418e980ad4b
diff --git a/playwright/e2e/persons/persons.spec.ts b/playwright/e2e/persons/persons.spec.tsindex 97429f0056d0..f14936f7e239 100644--- a/playwright/e2e/persons/persons.spec.ts+++ b/playwright/e2e/persons/persons.spec.ts@@ -79,6 +79,8 @@ test.describe('Persons', () => {await test.step('add a new text property and verify it appears', async () => {await persons.addProperty(propKey, 'test-value-123')const propsTable = persons.detailTable()+ // Wait for the new row to appear in the table before reading the value+ await expect(propsTable.row(propKey).tr).toBeVisible()const value = await propsTable.row(propKey).column('value')expect(value).toContain('test-value-123')})@@ -87,6 +89,7 @@ test.describe('Persons', () => {const emptyKey = randomString('empty-val')await persons.addProperty(emptyKey, '')const propsTable = persons.detailTable()+ await expect(propsTable.row(emptyKey).tr).toBeVisible()const value = await propsTable.row(emptyKey).column('value')expect(value).toBe('string')})@@ -95,6 +98,7 @@ test.describe('Persons', () => {const numericKey = randomString('numeric-val')await persons.addProperty(numericKey, '0')const propsTable = persons.detailTable()+ await expect(propsTable.row(numericKey).tr).toBeVisible()const value = await propsTable.row(numericKey).column('value')expect(value).toContain('0')})@@ -176,7 +180,7 @@ test.describe('Persons', () => {secondaryIds: secondaryData.results[0]?.distinct_ids,}},- { timeout: 30_000 }+ { timeout: 60_000, intervals: [1_000, 2_000, 5_000] }).toEqual({primaryIds: [primaryDistinctId],diff --git a/playwright/e2e/product-analytics/cohorts.spec.ts b/playwright/e2e/product-analytics/cohorts.spec.tsindex 93b8b1ba8fe3..5e9ffc5898c3 100644--- a/playwright/e2e/product-analytics/cohorts.spec.ts+++ b/playwright/e2e/product-analytics/cohorts.spec.ts@@ -54,7 +54,9 @@ test.describe('Cohorts', () => {// The panel's open state persists across the client-side nav. The open// button is unmounted while the panel is open, so only click it if the- // panel actually closed.+ // panel actually closed. Wait for the URL to advance to the new cohort+ // before checking visibility.+ await page.waitForURL(/\/cohorts\/\d+/)const reopenPanelButton = page.locator('[data-attr=open-context-panel-button]').first()if (await reopenPanelButton.isVisible().catch(() => false)) {await reopenPanelButton.click()diff --git a/playwright/utils/table-helper.ts b/playwright/utils/table-helper.tsindex 6b1bc9168c97..ba7dfa337f49 100644--- a/playwright/utils/table-helper.ts+++ b/playwright/utils/table-helper.ts@@ -16,10 +16,14 @@ async function cellsToArray(locator: Locator): Promise<string[]> {}export class TableRow {+ readonly tr: Locator+constructor(private readonly helper: TableHelper,- private readonly tr: Locator- ) {}+ tr: Locator+ ) {+ this.tr = tr+ }async column(nameOrIndex: string | number): Promise<string> {const index = typeof nameOrIndex === 'string' ? await this.helper.resolveColumnIndex(nameOrIndex) : nameOrIndex