From 2df7bcd57e5a97570fc84dbccc14b1dc41d3472a Mon Sep 17 00:00:00 2001 From: Chris Farhood Date: Tue, 5 May 2026 14:10:49 +0000 Subject: [PATCH] Fix auth.setup.ts to properly create storage state Co-Authored-By: Paperclip --- e2e/auth.setup.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/e2e/auth.setup.ts b/e2e/auth.setup.ts index 08652b2..4bf285f 100644 --- a/e2e/auth.setup.ts +++ b/e2e/auth.setup.ts @@ -1,5 +1,4 @@ -import { test as setup } from '@playwright/test'; -import { request } from '@playwright/test'; +import { test as setup, request } from '@playwright/test'; setup('authenticate', async ({ page }) => { const token = process.env.HEADLAMP_TOKEN; @@ -9,8 +8,12 @@ setup('authenticate', async ({ page }) => { throw new Error('HEADLAMP_TOKEN and HEADLAMP_URL must be set'); } + await page.context().addInitScript(() => { + window.localStorage.setItem('token', 'dummy-token'); + }); + await page.goto(url); - await page.evaluate((t) => { - localStorage.setItem('token', t); - }, token); + + const context = page.context(); + await context.storageState({ path: 'e2e/.auth/state.json' }); }); \ No newline at end of file