mirror of
https://github.com/bretzel-app/crumbs.git
synced 2026-10-12 20:06:57 +02:00
Generate random passwords in global-setup and share via temp file so all Playwright workers use the same credentials. Screenshot scripts use module-level crypto.randomUUID() since they run single-process. Unit test auth passwords also use randomUUID(). Eliminates security scanner alerts for passwords committed to git. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
730 B
TypeScript
26 lines
730 B
TypeScript
import { existsSync, unlinkSync, writeFileSync } from 'fs';
|
|
import { randomUUID } from 'crypto';
|
|
|
|
const TEST_DB = './data/test-crumbs.db';
|
|
export const TEST_CREDENTIALS_FILE = './data/test-credentials.json';
|
|
|
|
export default function globalSetup() {
|
|
// Clean test database before E2E run so each run starts fresh
|
|
for (const ext of ['', '-journal', '-wal', '-shm']) {
|
|
const path = `${TEST_DB}${ext}`;
|
|
if (existsSync(path)) {
|
|
unlinkSync(path);
|
|
}
|
|
}
|
|
|
|
// Generate random passwords for this test run, shared across all workers
|
|
writeFileSync(
|
|
TEST_CREDENTIALS_FILE,
|
|
JSON.stringify({
|
|
testPassword: `test-${randomUUID()}`,
|
|
collabPassword: `collab-${randomUUID()}`,
|
|
userPassword: `user-${randomUUID()}`
|
|
})
|
|
);
|
|
}
|