website refactor

This commit is contained in:
2026-01-17 22:55:03 +01:00
parent 64d9e7fd16
commit 69d4cce7f1
64 changed files with 1146 additions and 1014 deletions

View File

@@ -151,13 +151,13 @@ describe('SeedDemoUsers', () => {
const saveCalls = (authRepository.save as any).mock.calls;
// Check that driver, owner, steward, admin, systemowner, superadmin have primaryDriverId
// Check that all users have primaryDriverId
const usersWithPrimaryDriverId = saveCalls.filter((call: any) => {
const user: User = call[0];
return user.getPrimaryDriverId() !== undefined;
});
expect(usersWithPrimaryDriverId.length).toBe(6); // All except sponsor
expect(usersWithPrimaryDriverId.length).toBe(7); // All users
});
});

View File

@@ -39,7 +39,7 @@ export class SeedDemoUsers {
email: 'demo.sponsor@example.com',
password: 'Demo1234!',
needsAdminUser: false,
needsPrimaryDriverId: false,
needsPrimaryDriverId: true,
roles: ['sponsor'],
displayName: 'Jane Sponsor',
},
@@ -113,8 +113,18 @@ export class SeedDemoUsers {
}
private generatePrimaryDriverId(email: string, persistence: 'postgres' | 'inmemory'): string {
// Use the email as the seed for the primary driver ID
const seedKey = `primary-driver-${email}`;
// Use predefined IDs for demo users to match SeedRacingData
const demoDriverIds: Record<string, string> = {
'demo.driver@example.com': 'driver-1',
'demo.sponsor@example.com': 'driver-2',
'demo.owner@example.com': 'driver-3',
'demo.steward@example.com': 'driver-4',
'demo.admin@example.com': 'driver-5',
'demo.systemowner@example.com': 'driver-6',
'demo.superadmin@example.com': 'driver-7',
};
const seedKey = demoDriverIds[email] || `primary-driver-${email}`;
return this.generateDeterministicId(seedKey, persistence);
}