Fix auth.setup.ts to properly create storage state

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
2026-05-05 14:10:49 +00:00
committed by Hugh Hackman [agent]
parent 15d040b8ca
commit 2df7bcd57e
+8 -5
View File
@@ -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' });
});