Client-side fetch('/api/documents/{id}/file') bypassed the handleFetch hook
that injects the Authorization header, causing the browser to receive a 401
with WWW-Authenticate: Basic and show a native auth dialog.
Added a SvelteKit server route at /api/documents/[id]/file that proxies the
request through the server, where handleFetch injects the auth cookie correctly.
Also fixed E2E default password (admin → admin123) to match application.yaml.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
26 lines
892 B
TypeScript
26 lines
892 B
TypeScript
import { test as setup } from '@playwright/test';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
const authFile = path.join(__dirname, '.auth/user.json');
|
|
|
|
/**
|
|
* Logs in once and saves the session cookie so all E2E tests can reuse it.
|
|
* Configure credentials via environment variables:
|
|
* E2E_USERNAME (default: admin)
|
|
* E2E_PASSWORD (default: admin123)
|
|
*/
|
|
setup('authenticate', async ({ page }) => {
|
|
const username = process.env.E2E_USERNAME ?? 'admin';
|
|
const password = process.env.E2E_PASSWORD ?? 'admin123';
|
|
|
|
await page.goto('/login');
|
|
await page.getByLabel('Benutzername').fill(username);
|
|
await page.getByLabel('Passwort').fill(password);
|
|
await page.getByRole('button', { name: 'Anmelden' }).click();
|
|
await page.waitForURL('/');
|
|
|
|
await page.context().storageState({ path: authFile });
|
|
});
|