website refactor
This commit is contained in:
@@ -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
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user