test(ops): verify Docker persistence, browser workflows and document deployment
This commit is contained in:
1 parent
a58516e424
commit
8fa63415f1
35 files changed
+1105
No files matched your search
@@ -0,0 +1,23 @@
|
||||
import { execFileSync } from 'node:child_process';
|
||||
import postgres from 'postgres';
|
||||
import { hash } from '@node-rs/argon2';
|
||||
import { examples } from './fixtures';
|
||||
export default async function setup() {
|
||||
const url = process.env.TEST_DATABASE_URL!;
|
||||
if (!new URL(url).pathname.endsWith('_test'))
|
||||
throw new Error('E2E-Datenbank muss auf _test enden.');
|
||||
execFileSync(process.execPath, ['node_modules/tsx/dist/cli.mjs', 'scripts/migrate.ts'], {
|
||||
env: { ...process.env, DATABASE_URL: url },
|
||||
stdio: 'inherit',
|
||||
});
|
||||
const sql = postgres(url, { max: 1 });
|
||||
try {
|
||||
await sql`TRUNCATE sessions, admins, recipes, media, login_limits CASCADE`;
|
||||
await sql`INSERT INTO admins (username, password) VALUES ('testadmin', ${await hash(process.env.TEST_PASSWORD!, { algorithm: 2, memoryCost: 65536, timeCost: 3 })})`;
|
||||
for (const r of examples)
|
||||
await sql`INSERT INTO recipes (id, title, title_key, published, data) VALUES (${r.id!}, ${r.title}, ${r.title.toLowerCase()}, true, ${sql.json(r)})`;
|
||||
await sql`INSERT INTO recipes (title, title_key, published, data) VALUES ('Geheimer Entwurf', 'geheimer entwurf', false, ${sql.json({ ...examples[0], id: undefined, title: 'Geheimer Entwurf', published: false })})`;
|
||||
} finally {
|
||||
await sql.end();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user