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 fe9ac2845..000000000 Binary files a/features/status-dashboard/backend-api/data/db/status-dashboard.db-shm and /dev/null differ diff --git a/features/status-dashboard/backend-api/data/db/status-dashboard.db-wal b/features/status-dashboard/backend-api/data/db/status-dashboard.db-wal deleted file mode 100644 index e69de29bb..000000000