more fixes
This commit is contained in:
28
tests/cpad/auth.setup.ts
Normal file
28
tests/cpad/auth.setup.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
/**
|
||||
* cPad Authentication Setup
|
||||
*
|
||||
* This file is matched by the `cpad-setup` Playwright project (see playwright.config.ts).
|
||||
* It runs ONCE before all cpad tests, logs in as admin, and saves the browser
|
||||
* storage state to tests/.auth/admin.json so subsequent tests skip the login step.
|
||||
*
|
||||
* Run only this setup step:
|
||||
* npx playwright test --project=cpad-setup
|
||||
*/
|
||||
|
||||
import { test as setup } from '@playwright/test';
|
||||
import { loginAsAdmin, AUTH_FILE } from '../helpers/auth';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
setup('authenticate as cPad admin', async ({ page }) => {
|
||||
// Ensure the .auth directory exists
|
||||
const authDir = path.dirname(AUTH_FILE);
|
||||
if (!fs.existsSync(authDir)) {
|
||||
fs.mkdirSync(authDir, { recursive: true });
|
||||
}
|
||||
|
||||
await loginAsAdmin(page);
|
||||
|
||||
// Persist cookies + localStorage for the cpad project
|
||||
await page.context().storageState({ path: AUTH_FILE });
|
||||
});
|
||||
Reference in New Issue
Block a user