Massive backend refactoring done

This commit is contained in:
AG
2025-12-10 14:56:20 +02:00
parent 502943f7d0
commit 95a5e37748
47 changed files with 1898 additions and 1416 deletions

View File

@@ -37,13 +37,13 @@ export const test = base.extend<MyFixtures>({
const body = await response.json();
// If registration fails because we hit a collision (unlikely) or other error, fail the test
if (!response.ok()) {
if (!response.ok() || !body.success) {
console.error(`REGISTRATION FAILED: ${response.status()} ${response.statusText()}`);
console.error(`RESPONSE BODY: ${JSON.stringify(body, null, 2)}`);
throw new Error(`Failed to register user: ${JSON.stringify(body)}`);
}
return { email, password, id: body.user.id, token: body.token };
return { email, password, id: body.data.user.id, token: body.data.token };
};
// Use the fixture
@@ -65,7 +65,7 @@ export const test = base.extend<MyFixtures>({
try {
const { stdout, stderr } = await exec(`npx ts-node promote_admin.ts ${user.email}`, {
cwd: 'server',
env: { ...process.env, APP_MODE: 'test', DATABASE_URL: 'file:./prisma/test.db', DATABASE_URL_TEST: 'file:./prisma/test.db' }
env: { ...process.env, APP_MODE: 'test', DATABASE_URL: 'file:d:/Coding/gymflow/server/test.db', DATABASE_URL_TEST: 'file:d:/Coding/gymflow/server/test.db' }
});
if (stderr) {
console.error(`Promote Admin Stderr: ${stderr}`);
@@ -74,8 +74,10 @@ export const test = base.extend<MyFixtures>({
if (!stdout.includes(`User ${user.email} promoted to ADMIN`)) {
throw new Error('Admin promotion failed or unexpected output.');
}
} catch (error) {
} catch (error: any) {
console.error(`Error promoting user ${user.email} to ADMIN:`, error);
if (error.stdout) console.log(`Failed CMD Stdout: ${error.stdout}`);
if (error.stderr) console.error(`Failed CMD Stderr: ${error.stderr}`);
throw error;
}
return user;