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(playwright): replace deprecated playwright-test-base with workspace-test-base (#61762)

Georges-Antoine Assi3bf7e35ab5c2
diff --git a/.github/scripts/verify-playwright-new-tests-and-snapshots.sh b/.github/scripts/verify-playwright-new-tests-and-snapshots.sh
index a111af139c4d..2719754d6d56 100755
--- a/.github/scripts/verify-playwright-new-tests-and-snapshots.sh
+++ b/.github/scripts/verify-playwright-new-tests-and-snapshots.sh
@@ -66,6 +66,24 @@ if [ ${#tests_to_run[@]} -eq 0 ]; then
exit 0
fi
+# Verification runs serially (--workers=1), so total work is files × repeat. Wide
+# mechanical refactors can touch dozens of spec files; repeating each 10x would blow
+# past the job's 45-minute timeout. Scale the repeat count down to fit a file-run
+# budget, and below MIN_REPEAT repetitions there's no flake signal left — skip.
+MAX_TOTAL_FILE_RUNS=60
+MIN_REPEAT=2
+
+num_files=${#tests_to_run[@]}
+if ((num_files * REPEAT_COUNT > MAX_TOTAL_FILE_RUNS)); then
+ scaled_repeat=$((MAX_TOTAL_FILE_RUNS / num_files))
+ if ((scaled_repeat < MIN_REPEAT)); then
+ echo "Skipping flake verification: $num_files changed spec files exceed the time budget even at --repeat-each=$MIN_REPEAT (likely a broad mechanical refactor)"
+ exit 0
+ fi
+ echo "Scaling --repeat-each from $REPEAT_COUNT to $scaled_repeat: $num_files changed spec files exceed the $MAX_TOTAL_FILE_RUNS file-run budget"
+ REPEAT_COUNT=$scaled_repeat
+fi
+
echo "Verifying ${#tests_to_run[@]} file(s) with --repeat-each=$REPEAT_COUNT:"
printf " %s\n" "${tests_to_run[@]}"
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
index e5780d08fb55..d89ff38719b7 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.test.ts
@@ -244,6 +244,27 @@ describe('sessionRecordingDataCoordinatorLogic', () => {
])
.toDispatchActions([sessionRecordingEventUsageLogic.actionTypes.reportRecordingLoaded])
})
+
+ it('sends `recording loaded` event when full event data is the last to load', async () => {
+ // loadFullEventData shares the sessionEventsData loader, so a slow full-event-data
+ // response used to leave fullyLoaded false with nothing left to re-trigger the report
+ overrideSessionRecordingMocks({
+ postMocks: {
+ '/api/environments/:team_id/query/:kind': async (req) => {
+ const body = await req.json()
+ const query = body.query?.query || ''
+ if (query.includes('uuid in')) {
+ await new Promise((resolve) => setTimeout(resolve, 100))
+ }
+ return [200, recordingEventsJson]
+ },
+ },
+ })
+
+ await expectLogic(logic, () => {
+ logic.actions.loadSnapshots()
+ }).toDispatchActions([sessionRecordingEventUsageLogic.actionTypes.reportRecordingLoaded])
+ })
})
// TODO need deduplication tests for blob_v2 sources before we deprecate blob_v1
diff --git a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
index 7aadcdbbbc33..d8367408881a 100644
--- a/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
+++ b/frontend/src/scenes/session-recordings/player/sessionRecordingDataCoordinatorLogic.ts
@@ -85,7 +85,7 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
'registerWindowId',
],
eventsLogic,
- ['loadEvents', 'loadFullEventData', 'loadEventsSuccess'],
+ ['loadEvents', 'loadFullEventData', 'loadEventsSuccess', 'loadFullEventDataSuccess'],
commentsLogic,
[
'loadRecordingComments',
@@ -178,6 +178,12 @@ export const sessionRecordingDataCoordinatorLogic = kea<sessionRecordingDataCoor
actions.reportUsageIfFullyLoaded()
},
+ // loadFullEventData shares the sessionEventsData loader, so while it is in flight
+ // fullyLoaded is false — re-check once it settles or the loaded report can be skipped
+ loadFullEventDataSuccess: () => {
+ actions.reportUsageIfFullyLoaded()
+ },
+
loadSnapshotsForSourceSuccess: () => {
actions.reportUsageIfFullyLoaded()
actions.processSnapshotsAsync()
diff --git a/playwright/README.md b/playwright/README.md
index b585965ac1f6..e36fcb6b005b 100644
--- a/playwright/README.md
+++ b/playwright/README.md
@@ -10,7 +10,7 @@ Playwright tests are discovered from two locations (configured in `playwright.co
Shared fixtures, page models, and helpers live under `playwright/utils/`, `playwright/page-models/`, and `playwright/mocks/`. Import them from anywhere via TypeScript path aliases:
```ts
-import { expect, test } from '@playwright-utils/playwright-test-base'
+import { expect, test } from '@playwright-utils/workspace-test-base'
import { randomString } from '@playwright-utils'
import { InsightPage } from '@playwright-pages/insightPage'
```
diff --git a/playwright/e2e/auth-password-reset.spec.ts b/playwright/e2e/auth-password-reset.spec.ts
index 30350870a199..75566cf22c93 100644
--- a/playwright/e2e/auth-password-reset.spec.ts
+++ b/playwright/e2e/auth-password-reset.spec.ts
@@ -1,12 +1,19 @@
import { LoginPage } from '../page-models/loginPage'
-import { expect, test } from '../utils/playwright-test-base'
+import { randomString } from '../utils'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
const VALID_PASSWORD = 'hedgE-hog-123%'
test.describe('Password Reset', () => {
let loginPage: LoginPage
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
- test.beforeEach(async ({ page }) => {
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
await page.click('[data-attr=new-account-menu-button]')
await page.click('[data-attr=new-account-menu-logout-button]')
await expect(page).toHaveURL('/login')
@@ -19,10 +26,12 @@ test.describe('Password Reset', () => {
await expect(page.locator('[data-attr=forgot-password]')).toBeVisible({ timeout: 5000 })
await page.click('[data-attr="forgot-password"]')
await expect(page).toHaveURL('/reset?email=fake%40posthog.com')
- await page.fill('[data-attr="reset-email"]', '[email protected]')
+ // Use a unique email so the per-email reset throttle (6/day) doesn't trip under repeated runs
+ const resetEmail = `${randomString('reset')}@posthog.com`
+ await page.fill('[data-attr="reset-email"]', resetEmail)
await page.click('button[type=submit]')
await expect(page.getByText('Request received successfully!')).toBeVisible()
- await expect(page.getByText('[email protected]')).toBeVisible()
+ await expect(page.getByText(resetEmail)).toBeVisible()
})
test('Cannot reset with invalid token', async ({ page }) => {
diff --git a/playwright/e2e/auth.spec.ts b/playwright/e2e/auth.spec.ts
index 742e62f97228..9a35a11859cc 100644
--- a/playwright/e2e/auth.spec.ts
+++ b/playwright/e2e/auth.spec.ts
@@ -1,9 +1,17 @@
import { LoginPage } from '../page-models/loginPage'
-import { LOGIN_PASSWORD, LOGIN_USERNAME, expect, test } from '../utils/playwright-test-base'
+import { LOGIN_PASSWORD, LOGIN_USERNAME } from '../utils/playwright-test-core'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('Auth', () => {
let loginPage: LoginPage
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
await page.locator('[data-attr=new-account-menu-button]').click()
loginPage = new LoginPage(page)
})
diff --git a/playwright/e2e/batch-exports/batch-export-backfills.spec.ts b/playwright/e2e/batch-exports/batch-export-backfills.spec.ts
index 5c58cb363592..39d976a103f2 100644
--- a/playwright/e2e/batch-exports/batch-export-backfills.spec.ts
+++ b/playwright/e2e/batch-exports/batch-export-backfills.spec.ts
@@ -1,6 +1,6 @@
import { Page } from '@playwright/test'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
import { createMockBatchExport, MOCK_EXPORT_ID, setupBatchExportRoutes } from './batch-export-helpers'
async function setupBackfillRoutes(
@@ -76,6 +76,16 @@ async function setupBackfillRoutes(
}
test.describe('Batch export backfills', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Shows backfill estimate toast with cancel option after creating a backfill', async ({ page }) => {
await setupBackfillRoutes(page, {
backfillOnGet: (callCount) => {
diff --git a/playwright/e2e/batch-exports/batch-export-config.spec.ts b/playwright/e2e/batch-exports/batch-export-config.spec.ts
index bb1343094da9..000098998633 100644
--- a/playwright/e2e/batch-exports/batch-export-config.spec.ts
+++ b/playwright/e2e/batch-exports/batch-export-config.spec.ts
@@ -1,7 +1,17 @@
import { randomString } from '../../utils'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
test.describe('Batch export configuration', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Create new S3 batch export', async ({ page }) => {
const name = randomString('S3 Export')
const mockId = '01234567-0123-0123-0123-0123456789ab'
diff --git a/playwright/e2e/batch-exports/batch-export-logs.spec.ts b/playwright/e2e/batch-exports/batch-export-logs.spec.ts
index cef83934df63..110fcef3a55d 100644
--- a/playwright/e2e/batch-exports/batch-export-logs.spec.ts
+++ b/playwright/e2e/batch-exports/batch-export-logs.spec.ts
@@ -1,6 +1,6 @@
import { Page } from '@playwright/test'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
import { createMockBatchExport, MOCK_EXPORT_ID, setupBatchExportRoutes } from './batch-export-helpers'
async function setupLogsRoutes(page: Page): Promise<void> {
@@ -42,6 +42,16 @@ async function setupLogsRoutes(page: Page): Promise<void> {
}
test.describe('Batch export logs', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Renders logs viewer', async ({ page }) => {
await setupLogsRoutes(page)
diff --git a/playwright/e2e/batch-exports/batch-export-metrics.spec.ts b/playwright/e2e/batch-exports/batch-export-metrics.spec.ts
index b5e462abb3fc..a1ee92f24387 100644
--- a/playwright/e2e/batch-exports/batch-export-metrics.spec.ts
+++ b/playwright/e2e/batch-exports/batch-export-metrics.spec.ts
@@ -1,6 +1,6 @@
import { Page } from '@playwright/test'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
import { createMockBatchExport, MOCK_EXPORT_ID, setupBatchExportRoutes } from './batch-export-helpers'
async function setupMetricsRoutes(page: Page): Promise<void> {
@@ -24,6 +24,16 @@ async function setupMetricsRoutes(page: Page): Promise<void> {
}
test.describe('Batch export metrics', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Renders metrics content', async ({ page }) => {
await setupMetricsRoutes(page)
diff --git a/playwright/e2e/batch-exports/batch-export-runs.spec.ts b/playwright/e2e/batch-exports/batch-export-runs.spec.ts
index 56da759216d3..2f46c46d4f58 100644
--- a/playwright/e2e/batch-exports/batch-export-runs.spec.ts
+++ b/playwright/e2e/batch-exports/batch-export-runs.spec.ts
@@ -1,6 +1,6 @@
import { Page } from '@playwright/test'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
import { createMockBatchExport, MOCK_EXPORT_ID, setupBatchExportRoutes } from './batch-export-helpers'
async function setupRunsRoutes(
@@ -45,6 +45,16 @@ async function setupRunsRoutes(
}
test.describe('Batch export runs', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Renders empty runs table', async ({ page }) => {
await setupRunsRoutes(page)
diff --git a/playwright/e2e/before-onboarding.spec.ts b/playwright/e2e/before-onboarding.spec.ts
index bb6fff737f74..d774b9bac351 100644
--- a/playwright/e2e/before-onboarding.spec.ts
+++ b/playwright/e2e/before-onboarding.spec.ts
@@ -1,18 +1,15 @@
-import { expect, test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('Before Onboarding', () => {
- test.beforeAll(async ({ request }) => {
- await request.patch('/api/projects/1/', {
- data: { completed_snippet_onboarding: false },
- headers: { Authorization: 'Bearer e2e_demo_api_key' },
- })
+ // Use a fresh workspace without demo data to exercise reaching settings pages on a new org/team.
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ no_demo_data: true })
})
- test.afterAll(async ({ request }) => {
- await request.patch('/api/projects/1/', {
- data: { completed_snippet_onboarding: true },
- headers: { Authorization: 'Bearer e2e_demo_api_key' },
- })
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
})
test('Navigate to a settings page even when a product has not been set up', async ({ page }) => {
diff --git a/playwright/e2e/billing/billing-limits.spec.ts b/playwright/e2e/billing/billing-limits.spec.ts
index c4fa7d929335..f75bcb8c6d29 100644
--- a/playwright/e2e/billing/billing-limits.spec.ts
+++ b/playwright/e2e/billing/billing-limits.spec.ts
@@ -2,7 +2,7 @@ import { Page } from '@playwright/test'
import fs from 'fs'
import path from 'path'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
type BillingRouteHandlers = {
getResponse: (billingContent: Record<string, any>) => Record<string, any>
@@ -46,6 +46,16 @@ async function setupBillingRoutes(page: Page, handlers: BillingRouteHandlers): P
}
test.describe('Billing Limits', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Show no limits set and allow user to set one', async ({ page }) => {
await setupBillingRoutes(page, {
getResponse: (billingContent) => billingContent,
diff --git a/playwright/e2e/billing/billing.spec.ts b/playwright/e2e/billing/billing.spec.ts
index a552958b45a9..baa3a164b97d 100644
--- a/playwright/e2e/billing/billing.spec.ts
+++ b/playwright/e2e/billing/billing.spec.ts
@@ -1,10 +1,18 @@
import fs from 'fs'
import path from 'path'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
test.describe('Billing', () => {
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+
// This replicates cy.intercept('/api/billing/') with fixture
// We'll read the JSON from a fixture folder. Adjust the path as needed.
await page.route('**/api/billing/', async (route) => {
diff --git a/playwright/e2e/cdp/hog-function-backfills.spec.ts b/playwright/e2e/cdp/hog-function-backfills.spec.ts
index 653b737bc5d0..64737a5257ea 100644
--- a/playwright/e2e/cdp/hog-function-backfills.spec.ts
+++ b/playwright/e2e/cdp/hog-function-backfills.spec.ts
@@ -1,7 +1,7 @@
import { Page } from '@playwright/test'
import { mockFeatureFlags } from '../../utils/mockApi'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
import { createMockBatchExport, setupBatchExportRoutes } from '../batch-exports/batch-export-helpers'
const MOCK_HOG_FUNCTION_ID = 'hog-func-001'
@@ -109,6 +109,16 @@ async function setupHogFunctionBackfillRoutes(page: Page, options: { runs?: obje
}
test.describe('Hog function backfills tab', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Renders backfills table when navigating to backfills tab on a hog function destination', async ({ page }) => {
await setupHogFunctionBackfillRoutes(page)
diff --git a/playwright/e2e/event-definitions.spec.ts b/playwright/e2e/event-definitions.spec.ts
index f80b48d5cadf..53727b09b4b9 100644
--- a/playwright/e2e/event-definitions.spec.ts
+++ b/playwright/e2e/event-definitions.spec.ts
@@ -1,6 +1,17 @@
-import { expect, test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('Event Definitions', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ // Keep demo data: the test reads an existing event definition row and opens its recordings.
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
+ })
+
test('See recordings action', async ({ page }) => {
await page.goToMenuItem('datamanagement')
await page.goToMenuItem('event-definitions')
diff --git a/playwright/e2e/events.spec.ts b/playwright/e2e/events.spec.ts
index 166823428ea7..bd6c866b20de 100644
--- a/playwright/e2e/events.spec.ts
+++ b/playwright/e2e/events.spec.ts
@@ -1,13 +1,21 @@
import path from 'path'
-import { expect, test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('Events', () => {
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
+
await page.route('/api/event/values?key=%24browser', (route) =>
route.fulfill({
status: 200,
- body: JSON.stringify([{ name: '96' }, { name: '97' }]),
+ body: JSON.stringify([{ name: 'Chrome 145' }, { name: 'Firefox' }]),
})
)
@@ -18,41 +26,36 @@ test.describe('Events', () => {
})
)
- await page.route('/api/projects/*/property_definitions?is_feature_flag=false&search=&*', (route) =>
+ // The endpoint injects params (exclude_hidden, exclude_restricted, ...) between
+ // is_feature_flag and search, so match on the discriminating params regardless of order.
+ await page.route('**/property_definitions?*is_feature_flag=false*search=&*', (route) =>
route.fulfill({
status: 200,
path: path.resolve(__dirname, '../mocks/events/property_definitions.json'),
})
)
- await page.route('/api/projects/*/property_definitions?is_feature_flag=false&search=%24time*', (route) =>
+ await page.route('**/property_definitions?*is_feature_flag=false*search=%24time*', (route) =>
route.fulfill({
status: 200,
path: path.resolve(__dirname, '../mocks/events/only_time_property_definition.json'),
})
)
- await page.route('/api/projects/*/property_definitions?is_feature_flag=false&search=%24browser*', (route) =>
+ await page.route('**/property_definitions?*is_feature_flag=false*search=%24browser*', (route) =>
route.fulfill({
status: 200,
- path: path.resolve(__dirname, '../mocks/events/only_browser_version_property_definition.json'),
+ path: path.resolve(__dirname, '../mocks/events/browser_property_definitions.json'),
})
)
- await page.route('/api/projects/*/property_definitions?is_feature_flag=true*', (route) =>
+ await page.route('**/property_definitions?*is_feature_flag=true*', (route) =>
route.fulfill({
status: 200,
path: path.resolve(__dirname, '../mocks/events/feature_flag_property_definition.json'),
})
)
- await page.route('/api/event/values/?key=$browser_version', (route) =>
- route.fulfill({
- status: 200,
- body: JSON.stringify([{ name: '96' }, { name: '97' }]),
- })
- )
-
await page.goToMenuItem('activity')
await page.waitForURL('**/activity/explore')
})
diff --git a/playwright/e2e/logs/logs-alerts.spec.ts b/playwright/e2e/logs/logs-alerts.spec.ts
index 4f78fe897b3a..e073f3817f16 100644
--- a/playwright/e2e/logs/logs-alerts.spec.ts
+++ b/playwright/e2e/logs/logs-alerts.spec.ts
@@ -1,7 +1,7 @@
import { Page } from '@playwright/test'
import { mockFeatureFlags } from '../../utils/mockApi'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
const MOCK_ALERT_ID = '019d-mock-alert-id'
@@ -125,8 +125,8 @@ async function setupAlertMocks(
return { alert: handle }
}
-async function gotoAlertsList(page: Page): Promise<void> {
- await page.goto('/project/1/logs?activeTab=alerts')
+async function gotoAlertsList(page: Page, teamId: string): Promise<void> {
+ await page.goto(`/project/${teamId}/logs?activeTab=alerts`)
await page.evaluate(() => void (window as any).posthog?.reloadFeatureFlags?.())
await expect(page.getByTestId('logs-alerts-new')).toBeVisible({ timeout: 15000 })
}
@@ -148,7 +148,14 @@ async function addErrorSeverityFilter(page: Page): Promise<void> {
}
test.describe('Logs Alerts', () => {
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
await mockFeatureFlags(page, { 'logs-tabbed-view': true, 'logs-alerting': true })
})
@@ -156,7 +163,7 @@ test.describe('Logs Alerts', () => {
await setupAlertMocks(page)
await test.step('click-to-create lands on detail page in draft state', async () => {
- await gotoAlertsList(page)
+ await gotoAlertsList(page, workspace!.team_id)
await clickNewAlert(page)
await expect(page.getByTestId('scene-title-textarea')).toBeVisible()
await expect(page.getByTestId('logs-alert-enable-primary')).toBeVisible()
@@ -188,7 +195,7 @@ test.describe('Logs Alerts', () => {
test('disabled-banner Enable button works on a dirty draft (regression for save-then-enable)', async ({ page }) => {
await setupAlertMocks(page)
- await gotoAlertsList(page)
+ await gotoAlertsList(page, workspace!.team_id)
await clickNewAlert(page)
await addErrorSeverityFilter(page)
diff --git a/playwright/e2e/logs/logs.spec.ts b/playwright/e2e/logs/logs.spec.ts
index 358a3d202af7..a6e25546eddf 100644
--- a/playwright/e2e/logs/logs.spec.ts
+++ b/playwright/e2e/logs/logs.spec.ts
@@ -1,10 +1,18 @@
import path from 'path'
-import { expect, test } from '../../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../../utils/workspace-test-base'
test.describe('Logs', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
test.describe('UI integration tests (mocked API)', () => {
- test.beforeEach(async ({ page }) => {
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+
// Mock APIs BEFORE navigation to avoid race conditions
await page.route('**/api/environments/*/logs/query/', (route) =>
route.fulfill({
@@ -30,7 +38,7 @@ test.describe('Logs', () => {
})
)
- await page.goto('/project/1/logs')
+ await page.goto(`/project/${workspace!.team_id}/logs`)
await page.waitForLoadState('networkidle')
})
diff --git a/playwright/e2e/preflight.spec.ts b/playwright/e2e/preflight.spec.ts
index 2ce2c549f4f0..8fdfaa40156a 100644
--- a/playwright/e2e/preflight.spec.ts
+++ b/playwright/e2e/preflight.spec.ts
@@ -1,4 +1,4 @@
-import { expect, test } from '../utils/playwright-test-base'
+import { expect, test } from '../utils/workspace-test-base'
const preflightSuccessResponse = {
django: true,
diff --git a/playwright/e2e/product-analytics/cohorts.spec.ts b/playwright/e2e/product-analytics/cohorts.spec.ts
index 401178d26254..93b8b1ba8fe3 100644
--- a/playwright/e2e/product-analytics/cohorts.spec.ts
+++ b/playwright/e2e/product-analytics/cohorts.spec.ts
@@ -7,7 +7,7 @@ test.describe('Cohorts', () => {
test.beforeEach(async ({ page, playwrightSetup }) => {
// Dedicated empty workspace per test — no shared demo team, so the cohorts list
- // only ever contains what this test creates (see playwright-test-base deprecation).
+ // only ever contains what this test creates.
workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
await playwrightSetup.login(page, workspace)
diff --git a/playwright/e2e/signup.spec.ts b/playwright/e2e/signup.spec.ts
index b7f48a6d9e4f..72078b032366 100644
--- a/playwright/e2e/signup.spec.ts
+++ b/playwright/e2e/signup.spec.ts
@@ -1,6 +1,6 @@
import type { APIRequestContext, Page } from '@playwright/test'
-import { expect, test } from '../utils/playwright-test-base'
+import { expect, test } from '../utils/workspace-test-base'
const VALID_PASSWORD = 'hedgE-hog-123%'
diff --git a/playwright/e2e/system-status.spec.ts b/playwright/e2e/system-status.spec.ts
index 52f7a9cd9b6f..887091beb917 100644
--- a/playwright/e2e/system-status.spec.ts
+++ b/playwright/e2e/system-status.spec.ts
@@ -1,6 +1,16 @@
-import { expect, test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('System Status', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true, staff: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
+ })
+
test('System Status loaded', async ({ page }) => {
await page.locator('[data-attr=help-menu-button]').click()
await page.locator('[data-attr=help-menu-admin-button]').click()
diff --git a/playwright/e2e/web-analytics.spec.ts b/playwright/e2e/web-analytics.spec.ts
index 465bcd316a80..1f4dc6473f7a 100644
--- a/playwright/e2e/web-analytics.spec.ts
+++ b/playwright/e2e/web-analytics.spec.ts
@@ -1,6 +1,16 @@
-import { expect, test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
test.describe('Web Analytics', () => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.login(page, workspace!)
+ })
+
test('Can open add authorized URL form', async ({ page }) => {
await page.goto('/web')
// Open the domain filter dropdown
diff --git a/playwright/e2e/workflows-property-filter-category-dropdown.spec.ts b/playwright/e2e/workflows-property-filter-category-dropdown.spec.ts
index 61c73613ce2e..58673ef77737 100644
--- a/playwright/e2e/workflows-property-filter-category-dropdown.spec.ts
+++ b/playwright/e2e/workflows-property-filter-category-dropdown.spec.ts
@@ -1,7 +1,5 @@
-import { expect } from '@playwright/test'
-
import { mockFeatureFlags } from '../utils/mockApi'
-import { test } from '../utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '../utils/workspace-test-base'
const TRIGGER_NODE_ID = 'trigger_node'
const EXIT_NODE_ID = 'exit_node'
@@ -70,7 +68,16 @@ function buildConditionalBranchWorkflow(): Record<string, any> {
}
test.describe('Workflows conditional branch property filter category dropdown', () => {
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ // Log in (sets the session + CSRF cookie the test needs to create a hog_flow) without
+ // navigating into the app, so the feature flag mock is installed before the editor loads.
+ await playwrightSetup.login(page, workspace!)
await mockFeatureFlags(page, {
'taxonomic-filter-category-dropdown': 'pill',
})
diff --git a/playwright/mocks/events/only_browser_version_property_definition.json b/playwright/mocks/events/browser_property_definitions.json
similarity index 54%
rename from playwright/mocks/events/only_browser_version_property_definition.json
rename to playwright/mocks/events/browser_property_definitions.json
index 060cdcc5285e..90175c03bf5c 100644
--- a/playwright/mocks/events/only_browser_version_property_definition.json
+++ b/playwright/mocks/events/browser_property_definitions.json
@@ -1,8 +1,16 @@
{
- "count": 1,
+ "count": 2,
"next": null,
"previous": null,
"results": [
+ {
+ "id": "017dde0e-1cb5-0000-68b4-44835b7c8001",
+ "name": "$browser",
+ "is_numerical": false,
+ "query_usage_30_day": null,
+ "property_type": "String",
+ "is_seen_on_filtered_events": null
+ },
{
"id": "017dde0e-1cb5-0000-68b4-44835b7c894f",
"name": "$browser_version",
diff --git a/playwright/page-models/cohortPage.ts b/playwright/page-models/cohortPage.ts
index 23019146b324..11b253235852 100644
--- a/playwright/page-models/cohortPage.ts
+++ b/playwright/page-models/cohortPage.ts
@@ -2,7 +2,7 @@ import { Page } from '@playwright/test'
import { delay } from 'lib/utils'
-import { expect } from '../utils/playwright-test-base'
+import { expect } from '../utils/workspace-test-base'
export class CohortPage {
constructor(private readonly page: Page) {}
diff --git a/playwright/utils/playwright-setup.ts b/playwright/utils/playwright-setup.ts
index 0e5290b09f6b..14bff88b9cbf 100644
--- a/playwright/utils/playwright-setup.ts
+++ b/playwright/utils/playwright-setup.ts
@@ -66,6 +66,7 @@ export interface PlaywrightWorkspaceSetupData {
use_current_time?: boolean
skip_onboarding?: boolean
no_demo_data?: boolean
+ staff?: boolean
insight_variables?: PlaywrightSetupVariable[]
insights?: PlaywrightSetupInsight[]
dashboards?: PlaywrightSetupDashboard[]
diff --git a/playwright/utils/playwright-test-base.ts b/playwright/utils/playwright-test-base.ts
deleted file mode 100644
index a69be2312a56..000000000000
--- a/playwright/utils/playwright-test-base.ts
+++ /dev/null
@@ -1,53 +0,0 @@
-import '@playwright/test'
-
-import { urls } from 'scenes/urls'
-
-import { LOGIN_PASSWORD, LOGIN_USERNAME, test as coreTest } from './playwright-test-core'
-
-/**
- * Legacy Playwright test base with automatic login against the shared demo team.
- *
- * @deprecated New tests should use `workspace-test-base.ts`, which creates a
- * dedicated workspace per test via the setup_test endpoint. The legacy base shares
- * a single team across every spec that imports it, so any insight/cohort/survey/etc.
- * created by one test is visible to the others — the four CI Playwright workers
- * compound this into nondeterministic failures based on ordering.
- *
- * Migration plan:
- * 1. For each spec on this base, decide if it depends on demo-team seed data
- * (grep for `is_demo`, `Test-Cohort`, `CohortPage`, hardcoded demo references).
- * 2. If yes: the seed needs to be migrated into setup_test fixtures before the
- * spec can move. Known seed-dependent specs at time of writing:
- * - playwright/e2e/surveys/crud.spec.ts (uses `is_demo` person property)
- * - playwright/e2e/product-analytics/cohorts.spec.ts (uses Test-Cohort fixtures)
- * 3. If no: swap the import to `./workspace-test-base` and call
- * `playwrightSetup.createWorkspace()` + `playwrightSetup.login()` explicitly.
- *
- * Endgame is deleting this file.
- */
-export const test = coreTest.extend<{ loginBeforeTests: void }>({
- // this auto fixture makes sure we log in before every test (maintains legacy behavior)
- loginBeforeTests: [
- async ({ page }, use) => {
- // Perform authentication via API
- await page.request.post('/api/login/', {
- data: {
- email: LOGIN_USERNAME,
- password: LOGIN_PASSWORD,
- },
- })
- await page.goto(urls.projectRoot())
-
- // Continue with tests
- // eslint-disable-next-line react-hooks/rules-of-hooks
- await use()
-
- // any teardown would go here
- },
- { auto: true },
- ],
-})
-
-// Re-export everything for backwards compatibility
-export { expect } from '@playwright/test'
-export { LOGIN_USERNAME, LOGIN_PASSWORD } from './playwright-test-core'
diff --git a/playwright/utils/playwright-test-core.ts b/playwright/utils/playwright-test-core.ts
index 0429fc08dd28..2bf6a4a9d110 100644
--- a/playwright/utils/playwright-test-core.ts
+++ b/playwright/utils/playwright-test-core.ts
@@ -13,7 +13,7 @@ declare module '@playwright/test' {
/**
* Core Playwright test base with page extensions but NO automatic login
- * Use this as the foundation for both legacy tests and new workspace-based tests
+ * Use this as the foundation for workspace-based tests
*/
export const test = base.extend<{ page: Page }>({
page: async ({ page }, use) => {
diff --git a/playwright/utils/workspace-test-base.ts b/playwright/utils/workspace-test-base.ts
index baec0e397c5b..c9337eaf6c3a 100644
--- a/playwright/utils/workspace-test-base.ts
+++ b/playwright/utils/workspace-test-base.ts
@@ -4,8 +4,8 @@
* This provides clean test fixtures for creating PostHog workspaces
* (organizations, projects, teams) before running tests.
*
- * Unlike the legacy playwright-test-base, this does NOT auto-login,
- * giving you full control over authentication with workspace-specific users.
+ * This does NOT auto-login — you get full control over authentication with
+ * workspace-specific users by calling playwrightSetup.login() explicitly.
*/
/* eslint-disable react-hooks/rules-of-hooks */
import { PlaywrightSetup, PlaywrightWorkspaceSetupResult, createPlaywrightSetup } from './playwright-setup'
diff --git a/posthog/test/playwright_setup_functions.py b/posthog/test/playwright_setup_functions.py
index 8b94aa556532..810676fb48a8 100644
--- a/posthog/test/playwright_setup_functions.py
+++ b/posthog/test/playwright_setup_functions.py
@@ -6,6 +6,7 @@ from datetime import datetime
from enum import StrEnum
from typing import Any, Protocol, runtime_checkable
+from django.conf import settings
from django.utils import timezone
from pydantic import BaseModel
@@ -13,7 +14,7 @@ from pydantic import BaseModel
from posthog.clickhouse.query_tagging import Feature, Product, tags_context
from posthog.constants import AvailableFeature
from posthog.management.commands.generate_demo_data import Command as GenerateDemoDataCommand
-from posthog.models import PersonalAPIKey, Team, User
+from posthog.models import OrganizationMembership, PersonalAPIKey, Team, User
from posthog.models.utils import hash_key_value, mask_key_value
from products.dashboards.backend.models.dashboard import Dashboard
@@ -75,6 +76,7 @@ class PlaywrightWorkspaceSetupData(BaseModel):
use_current_time: bool | None = None
skip_onboarding: bool | None = None
no_demo_data: bool | None = None
+ staff: bool | None = None
insight_variables: list[PlaywrightSetupVariable] | None = None
insights: list[PlaywrightSetupInsight] | None = None
dashboards: list[PlaywrightSetupDashboard] | None = None
@@ -144,7 +146,11 @@ def create_organization_with_team(
organization=organization,
has_completed_onboarding_for={"product_analytics": True},
)
- user = User.objects.create_and_join(organization, user_email, user_password)
+ # The user creates the organization, so they own it. Without owner-level access,
+ # admin-only areas (e.g. billing) render a "restricted to organization admins" page.
+ user = User.objects.create_and_join(
+ organization, user_email, user_password, level=OrganizationMembership.Level.OWNER
+ )
else:
command = GenerateDemoDataCommand()
@@ -213,7 +219,13 @@ def create_organization_with_team(
# Skip the post-login /account/credential-review interstitial that fires for users with unreviewed PersonalAPIKey
user.credentials_reviewed_at = timezone.now()
- user.save(update_fields=["credentials_reviewed_at"])
+ # The system-status help-menu link checks the Django is_staff flag (not org-level admin), so the
+ # spec needs it. is_staff is powerful, so only grant it under E2E_TESTING/CI — not DEBUG alone.
+ update_fields = ["credentials_reviewed_at"]
+ if data.staff and (getattr(settings, "E2E_TESTING", False) or getattr(settings, "CI", False)):
+ user.is_staff = True
+ update_fields.append("is_staff")
+ user.save(update_fields=update_fields)
# Skip all onboarding tasks if requested (prevents Quick Start popover in tests)
if data.skip_onboarding:
diff --git a/products/surveys/frontend/e2e/crud.spec.ts b/products/surveys/frontend/e2e/crud.spec.ts
index 754526e54da4..8c3e4166b93c 100644
--- a/products/surveys/frontend/e2e/crud.spec.ts
+++ b/products/surveys/frontend/e2e/crud.spec.ts
@@ -1,5 +1,5 @@
import { randomString } from '@playwright-utils'
-import { expect, test } from '@playwright-utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '@playwright-utils/workspace-test-base'
import { Page } from '@playwright/test'
async function deleteSurvey(page: Page, name: string): Promise<void> {
@@ -56,9 +56,16 @@ test.describe.configure({ mode: 'serial' })
test.describe('CRUD Survey', () => {
let name: string
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
- test.beforeEach(async ({ page }) => {
+ // Keep demo data: one test targets the `email` person property in the taxonomic filter.
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
name = randomString('survey-')
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
await page.goToMenuItem('surveys')
})
@@ -110,8 +117,8 @@ test.describe('CRUD Survey', () => {
await page.getByRole('button', { name: 'Add property targeting' }).click()
await page.getByRole('button', { name: 'Add condition', exact: true }).click()
- await page.locator('[data-attr=taxonomic-filter-searchfield]').fill('is_demo')
- await page.locator('.taxonomic-list-row').getByText('is_demo').first().click()
+ await page.locator('[data-attr=taxonomic-filter-searchfield]').fill('email')
+ await page.locator('.taxonomic-list-row').getByText('email').first().click()
await page.locator('span').filter({ hasText: 'Enter value...' }).click()
await page.getByPlaceholder('Enter value...').fill('t')
diff --git a/products/surveys/frontend/e2e/quickcreate.spec.ts b/products/surveys/frontend/e2e/quickcreate.spec.ts
index a0114ef5430d..1c741bd5a4a8 100644
--- a/products/surveys/frontend/e2e/quickcreate.spec.ts
+++ b/products/surveys/frontend/e2e/quickcreate.spec.ts
@@ -95,7 +95,7 @@ test.describe('Quick create survey from feature flag', () => {
test.beforeEach(async ({ page, playwrightSetup }) => {
// Dedicated empty workspace per test — no shared demo team, so the feature-flag
- // list only contains the flag this test creates (see playwright-test-base deprecation).
+ // list only contains the flag this test creates.
// Seed a *recent* $autocapture event: the survey event picker (Events taxonomic list)
// sends exclude_stale=true, which drops definitions whose last_seen_at is >30 days old —
// so a fixed past timestamp never surfaced "Autocapture". `now` keeps it non-stale.
diff --git a/products/surveys/frontend/e2e/settings.spec.ts b/products/surveys/frontend/e2e/settings.spec.ts
index 495b40023ac2..4388213013d3 100644
--- a/products/surveys/frontend/e2e/settings.spec.ts
+++ b/products/surveys/frontend/e2e/settings.spec.ts
@@ -1,8 +1,15 @@
-import { expect, test } from '@playwright-utils/playwright-test-base'
+import { PlaywrightWorkspaceSetupResult, expect, test } from '@playwright-utils/workspace-test-base'
import { Page } from '@playwright/test'
test.describe('Survey Settings', () => {
- test.beforeEach(async ({ page }) => {
+ let workspace: PlaywrightWorkspaceSetupResult | null = null
+
+ test.beforeAll(async ({ playwrightSetup }) => {
+ workspace = await playwrightSetup.createWorkspace({ skip_onboarding: true, no_demo_data: true })
+ })
+
+ test.beforeEach(async ({ page, playwrightSetup }) => {
+ await playwrightSetup.loginAndNavigateToTeam(page, workspace!)
await page.goToMenuItem('surveys')
})
diff --git a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.test.ts b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.test.ts
index b1ed86be7744..14146649fd88 100644
--- a/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/panel/testing/hogFlowEditorNotificationTestLogic.test.ts
@@ -1,5 +1,4 @@
-import { resetContext } from 'kea'
-import { expectLogic, testUtilsPlugin } from 'kea-test-utils'
+import { expectLogic } from 'kea-test-utils'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -24,10 +23,6 @@ describe('hogFlowEditorNotificationTestLogic', () => {
localStorage.clear()
sessionStorage.clear()
- resetContext({
- plugins: [testUtilsPlugin],
- })
-
useMocks({
get: {
'/api/environments/:team_id/persons/': { results: [] },