Skip to content

Commit

Permalink
less flaky
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Dec 29, 2024
1 parent 331916d commit 66a2761
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions playwright/session-recording/opting-out.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ async function startWith(config: Partial<PostHogConfig>, page: Page, context: Br
// there will be a decide call
const decideResponse = page.waitForResponse('**/decide/*')

// but no recorder or snapshot call, because we're opting out
void expect(page.waitForResponse('**/recorder.js*', { timeout: 250 })).rejects.toThrowError('Timeout')
void expect(page.waitForResponse('**/ses/*', { timeout: 250 })).rejects.toThrowError('Timeout')

await start(
{
options: config,
Expand All @@ -35,14 +31,22 @@ async function startWith(config: Partial<PostHogConfig>, page: Page, context: Br

test.describe('Session Recording - opting out', () => {
test('does not capture events when config opts out by default', async ({ page, context }) => {
// but no recorder or snapshot call, because we're opting out
void expect(page.waitForResponse('**/recorder.js*', { timeout: 250 })).rejects.toThrowError('Timeout')
void expect(page.waitForResponse('**/ses/*', { timeout: 250 })).rejects.toThrowError('Timeout')
await startWith({ opt_out_capturing_by_default: true }, page, context)

await page.locator('[data-cy-input]').type('hello posthog!')
await page.waitForTimeout(250) // short delay since there's no snapshot to wait for
const capturedEvents = await page.capturedEvents()
expect(capturedEvents).toEqual([])
})

test('does not capture recordings when config disables session recording', async ({ page, context }) => {
// but no recorder or snapshot call, because we're opting out
void expect(page.waitForResponse('**/recorder.js*', { timeout: 250 })).rejects.toThrowError('Timeout')
void expect(page.waitForResponse('**/ses/*', { timeout: 250 })).rejects.toThrowError('Timeout')

await startWith({ disable_session_recording: true }, page, context)

await page.locator('[data-cy-input]').type('hello posthog!')
Expand Down

0 comments on commit 66a2761

Please sign in to comment.