Skip to content

Commit a166e33

Browse files
authored
fix(people): answer the cookie consent card in the people e2e so it can't block mobile taps (#10101)
1 parent e5cbc17 commit a166e33

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

‎apps/sim/scripts/test-people-e2e.ts‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import assert from 'node:assert/strict'
22
import { mkdir, writeFile } from 'node:fs/promises'
33
import { join } from 'node:path'
4+
import type { Page } from '@playwright/test'
45
import { assertDisposableTestDatabaseUrl } from '@sim/db/testing/test-infrastructure'
56
import { createLogger } from '@sim/logger'
67
import { getErrorMessage } from '@sim/utils/errors'
@@ -19,6 +20,21 @@ import postgres from 'postgres'
1920
*/
2021
const 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: /^(Reject all|Accept all)$/ })
33+
.first()
34+
.click()
35+
)
36+
}
37+
2238
function 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

Comments
 (0)