From 24665d607d57e2087b0e334fd910003deb33fb16 Mon Sep 17 00:00:00 2001 From: Lilith Date: Sun, 1 Feb 2026 02:52:20 -0800 Subject: [PATCH] =?UTF-8?q?chore(helpers):=20=F0=9F=94=A7=20Update=20helpe?= =?UTF-8?q?r=20files:=20age-gate.ts,=20status-dashboard.db-shm,=20and=20re?= =?UTF-8?q?lated=20utility=20scripts?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Lilith Autocommit --- .../frontend-public/e2e/helpers/age-gate.ts | 63 +++++++++++++----- .../data/db/status-dashboard.db-shm | Bin 32768 -> 0 bytes .../data/db/status-dashboard.db-wal | 0 3 files changed, 45 insertions(+), 18 deletions(-) delete mode 100644 features/status-dashboard/backend-api/data/db/status-dashboard.db-shm delete mode 100644 features/status-dashboard/backend-api/data/db/status-dashboard.db-wal diff --git a/features/landing/frontend-public/e2e/helpers/age-gate.ts b/features/landing/frontend-public/e2e/helpers/age-gate.ts index 233bf0adb..3ba2eaed7 100755 --- a/features/landing/frontend-public/e2e/helpers/age-gate.ts +++ b/features/landing/frontend-public/e2e/helpers/age-gate.ts @@ -34,6 +34,10 @@ interface AgeVerificationStatus { * Use this in beforeEach for tests that need to test app functionality * without interacting with the age gate. * + * In dev mode, AgeGateWrapper clears both localStorage and sessionStorage + * on mount. To survive this, we override removeItem/clear to preserve + * the bypass value for the age gate key. + * * @param page - Playwright page object * @example * test.beforeEach(async ({ page }) => { @@ -42,16 +46,48 @@ interface AgeVerificationStatus { * }) */ export async function bypassAgeGate(page: Page): Promise { - // Use addInitScript to set localStorage BEFORE page loads - // This runs before any page scripts and avoids the age gate flash await page.addInitScript((key) => { - const verificationStatus = { + const verificationStatus = JSON.stringify({ isVerified: true, method: 'self-declaration', tier: 1, verifiedAt: new Date().toISOString(), + }) + + // Set initial value in both storages + localStorage.setItem(key, verificationStatus) + sessionStorage.setItem(key, verificationStatus) + + // Prevent AgeGateWrapper's dev-mode cleanup from removing the bypass + const origLocalRemove = localStorage.removeItem.bind(localStorage) + localStorage.removeItem = function(k: string) { + if (k === key) { + localStorage.setItem(key, verificationStatus) + return + } + return origLocalRemove(k) + } + + const origSessionRemove = sessionStorage.removeItem.bind(sessionStorage) + sessionStorage.removeItem = function(k: string) { + if (k === key) { + sessionStorage.setItem(key, verificationStatus) + return + } + return origSessionRemove(k) + } + + const origLocalClear = localStorage.clear.bind(localStorage) + localStorage.clear = function() { + origLocalClear() + localStorage.setItem(key, verificationStatus) + } + + const origSessionClear = sessionStorage.clear.bind(sessionStorage) + sessionStorage.clear = function() { + origSessionClear() + sessionStorage.setItem(key, verificationStatus) } - localStorage.setItem(key, JSON.stringify(verificationStatus)) }, AGE_VERIFICATION_STORAGE_KEY) } @@ -59,19 +95,15 @@ export async function bypassAgeGate(page: Page): Promise { * Clear age verification from localStorage * * Use this to reset to unverified state for testing age gate behavior. - * This adds a one-time init script that only runs on the next page load. - * - * NOTE: For tests that navigate to multiple pages and need verification to persist, - * use clearAgeVerificationOnce() which doesn't affect subsequent navigations. + * NOTE: This clears on EVERY subsequent page load in this context. + * For one-time clearing, use clearAgeVerificationOnce(). * * @param page - Playwright page object */ export async function clearAgeVerification(page: Page): Promise { - // Use addInitScript to clear localStorage BEFORE page loads - // NOTE: This clears on EVERY subsequent page load in this context. - // For one-time clearing, use clearAgeVerificationOnce(). await page.addInitScript((key) => { localStorage.removeItem(key) + sessionStorage.removeItem(key) }, AGE_VERIFICATION_STORAGE_KEY) } @@ -79,22 +111,20 @@ export async function clearAgeVerification(page: Page): Promise { * Clear age verification from localStorage once (current page only) * * Unlike clearAgeVerification(), this only clears for the current page - * and doesn't affect subsequent navigations. Use this when testing - * persistence across routes. + * and doesn't affect subsequent navigations. * * @param page - Playwright page object */ export async function clearAgeVerificationOnce(page: Page): Promise { await page.evaluate((key) => { localStorage.removeItem(key) + sessionStorage.removeItem(key) }, AGE_VERIFICATION_STORAGE_KEY) } /** * Verify through the age gate by clicking the confirm button * - * Use this when you need to test the actual age gate flow. - * * @param page - Playwright page object * @example * test('should verify through age gate', async ({ page }) => { @@ -105,16 +135,13 @@ export async function clearAgeVerificationOnce(page: Page): Promise { * }) */ export async function verifyThroughAgeGate(page: Page): Promise { - // Wait for age gate modal to appear const ageGate = page.getByTestId('age-gate') await expect(ageGate).toBeVisible({ timeout: 10000 }) - // Click the confirm button const confirmButton = page.getByTestId('age-gate-confirm') await expect(confirmButton).toBeVisible() await confirmButton.click() - // Wait for age gate to close await expect(ageGate).not.toBeVisible({ timeout: 5000 }) } diff --git a/features/status-dashboard/backend-api/data/db/status-dashboard.db-shm b/features/status-dashboard/backend-api/data/db/status-dashboard.db-shm deleted file mode 100644 index fe9ac2845eca6fe6da8a63cd096d9cf9e24ece10..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 32768 zcmeIuAr62r3