11import assert from 'node:assert/strict'
22import { mkdir , writeFile } from 'node:fs/promises'
33import { join } from 'node:path'
4+ import type { Page } from '@playwright/test'
45import { assertDisposableTestDatabaseUrl } from '@sim/db/testing/test-infrastructure'
56import { createLogger } from '@sim/logger'
67import { getErrorMessage } from '@sim/utils/errors'
@@ -19,6 +20,21 @@ import postgres from 'postgres'
1920 */
2021const logger = createLogger ( 'PeopleE2E' )
2122
23+ /**
24+ * Answers the cookie consent card whenever it appears, the way a visitor would. It shows only
25+ * where the visitor's jurisdiction asks for consent, after the page loads, and on a phone-width
26+ * viewport it docks over the chart's controls, so taps beneath it would never land.
27+ */
28+ async function answerConsentPrompt ( page : Page ) {
29+ const prompt = page . getByRole ( 'region' , { name : 'Cookie preferences' } )
30+ await page . addLocatorHandler ( prompt , ( ) =>
31+ prompt
32+ . getByRole ( 'button' , { name : / ^ ( R e j e c t a l l | A c c e p t a l l ) $ / } )
33+ . first ( )
34+ . click ( )
35+ )
36+ }
37+
2238function requiredEnvironment ( name : string ) : string {
2339 const value = process . env [ name ]
2440 assert ( value , `${ name } must be explicitly provided` )
@@ -555,6 +571,7 @@ async function run() {
555571 try {
556572 await mkdir ( screenshotDir , { recursive : true } )
557573 const page = await browser . newPage ( { viewport : { width : 1440 , height : 900 } } )
574+ await answerConsentPrompt ( page )
558575 page . setDefaultTimeout ( 60_000 )
559576 await page
560577 . context ( )
@@ -734,6 +751,7 @@ async function run() {
734751 await expect ( focused ( 'Maya Chen' ) ) . toBeVisible ( )
735752
736753 const empty = await browser . newPage ( { viewport : { width : 1280 , height : 800 } } )
754+ await answerConsentPrompt ( empty )
737755 empty . setDefaultTimeout ( 60_000 )
738756 await empty
739757 . context ( )
@@ -756,6 +774,7 @@ async function run() {
756774 hasTouch : true ,
757775 viewport : { width : 390 , height : 844 } ,
758776 } )
777+ await answerConsentPrompt ( mobile )
759778 mobile . setDefaultTimeout ( 60_000 )
760779 await mobile
761780 . context ( )
@@ -808,6 +827,7 @@ async function run() {
808827 await sql `insert into people_directory_sync (organization_id, source, source_target, next_sync_at)
809828 values (${ teamOrg } , 'okta', 'draft.okta.com', now() + interval '1 hour')`
810829 const page = await browser . newPage ( )
830+ await answerConsentPrompt ( page )
811831 page . setDefaultTimeout ( 60_000 )
812832 await page
813833 . context ( )
0 commit comments