fix issues
This commit is contained in:
@@ -34,7 +34,7 @@ describe('AuthController', () => {
|
||||
const params: SignupParamsDTO = {
|
||||
email: 'test@example.com',
|
||||
password: 'password123',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
iracingCustomerId: '12345',
|
||||
primaryDriverId: 'driver1',
|
||||
avatarUrl: 'http://example.com/avatar.jpg',
|
||||
@@ -44,7 +44,7 @@ describe('AuthController', () => {
|
||||
user: {
|
||||
userId: 'user1',
|
||||
email: 'test@example.com',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
},
|
||||
};
|
||||
(service.signupWithEmail as Mock).mockResolvedValue(session);
|
||||
@@ -67,7 +67,7 @@ describe('AuthController', () => {
|
||||
user: {
|
||||
userId: 'user1',
|
||||
email: 'test@example.com',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
},
|
||||
};
|
||||
(service.loginWithEmail as Mock).mockResolvedValue(session);
|
||||
@@ -86,7 +86,7 @@ describe('AuthController', () => {
|
||||
user: {
|
||||
userId: 'user1',
|
||||
email: 'test@example.com',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
},
|
||||
};
|
||||
(service.getCurrentSession as Mock).mockResolvedValue(session);
|
||||
|
||||
@@ -69,7 +69,7 @@ describe('AuthService - New Methods', () => {
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
forgotPasswordUseCase as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
new FakeAuthSessionPresenter() as any,
|
||||
@@ -175,8 +175,9 @@ describe('AuthService - New Methods', () => {
|
||||
const demoLoginPresenter = new FakeDemoLoginPresenter();
|
||||
const mockUser = {
|
||||
getId: () => ({ value: 'demo-user-123' }),
|
||||
getDisplayName: () => 'Demo Driver',
|
||||
getDisplayName: () => 'Alex Johnson',
|
||||
getEmail: () => 'demo.driver@example.com',
|
||||
getPrimaryDriverId: () => undefined,
|
||||
};
|
||||
|
||||
const demoLoginUseCase = {
|
||||
@@ -210,17 +211,20 @@ describe('AuthService - New Methods', () => {
|
||||
const result = await service.demoLogin({ role: 'driver' });
|
||||
|
||||
expect(demoLoginUseCase.execute).toHaveBeenCalledWith({ role: 'driver' });
|
||||
expect(identitySessionPort.createSession).toHaveBeenCalledWith({
|
||||
id: 'demo-user-123',
|
||||
displayName: 'Demo Driver',
|
||||
email: 'demo.driver@example.com',
|
||||
});
|
||||
expect(identitySessionPort.createSession).toHaveBeenCalledWith(
|
||||
{
|
||||
id: 'demo-user-123',
|
||||
displayName: 'Alex Johnson',
|
||||
email: 'demo.driver@example.com',
|
||||
},
|
||||
undefined
|
||||
);
|
||||
expect(result).toEqual({
|
||||
token: 'demo-token-123',
|
||||
user: {
|
||||
userId: 'demo-user-123',
|
||||
email: 'demo.driver@example.com',
|
||||
displayName: 'Demo Driver',
|
||||
displayName: 'Alex Johnson',
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ describe('AuthService', () => {
|
||||
{
|
||||
getCurrentSession: vi.fn(async () => ({
|
||||
token: 't1',
|
||||
user: { id: 'u1', email: null, displayName: 'D' },
|
||||
user: { id: 'u1', email: null, displayName: 'John' },
|
||||
})),
|
||||
createSession: vi.fn(),
|
||||
} as any,
|
||||
@@ -76,7 +76,7 @@ describe('AuthService', () => {
|
||||
|
||||
await expect(service.getCurrentSession()).resolves.toEqual({
|
||||
token: 't1',
|
||||
user: { userId: 'u1', email: '', displayName: 'D' },
|
||||
user: { userId: 'u1', email: '', displayName: 'John' },
|
||||
});
|
||||
});
|
||||
|
||||
@@ -89,7 +89,7 @@ describe('AuthService', () => {
|
||||
|
||||
const signupUseCase = {
|
||||
execute: vi.fn(async () => {
|
||||
authSessionPresenter.present({ userId: 'u2', email: 'e2', displayName: 'd2' });
|
||||
authSessionPresenter.present({ userId: 'u2', email: 'e2', displayName: 'Jane Smith' });
|
||||
return Result.ok(undefined);
|
||||
}),
|
||||
};
|
||||
@@ -113,20 +113,20 @@ describe('AuthService', () => {
|
||||
const session = await service.signupWithEmail({
|
||||
email: 'e2',
|
||||
password: 'p2',
|
||||
displayName: 'd2',
|
||||
displayName: 'Jane Smith',
|
||||
} as any);
|
||||
|
||||
expect(signupUseCase.execute).toHaveBeenCalledWith({
|
||||
email: 'e2',
|
||||
password: 'p2',
|
||||
displayName: 'd2',
|
||||
displayName: 'Jane Smith',
|
||||
});
|
||||
expect(identitySessionPort.createSession).toHaveBeenCalledWith({
|
||||
id: 'u2',
|
||||
displayName: 'd2',
|
||||
displayName: 'Jane Smith',
|
||||
email: 'e2',
|
||||
});
|
||||
expect(session).toEqual({ token: 't2', user: { userId: 'u2', email: 'e2', displayName: 'd2' } });
|
||||
expect(session).toEqual({ token: 't2', user: { userId: 'u2', email: 'e2', displayName: 'Jane Smith' } });
|
||||
});
|
||||
|
||||
it('signupWithEmail throws with fallback when no details.message', async () => {
|
||||
@@ -147,7 +147,7 @@ describe('AuthService', () => {
|
||||
);
|
||||
|
||||
await expect(
|
||||
service.signupWithEmail({ email: 'e2', password: 'p2', displayName: 'd2' } as any),
|
||||
service.signupWithEmail({ email: 'e2', password: 'p2', displayName: 'Jane Smith' } as any),
|
||||
).rejects.toThrow('Signup failed');
|
||||
});
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('AuthService', () => {
|
||||
|
||||
const loginUseCase = {
|
||||
execute: vi.fn(async () => {
|
||||
authSessionPresenter.present({ userId: 'u3', email: 'e3', displayName: 'd3' });
|
||||
authSessionPresenter.present({ userId: 'u3', email: 'e3', displayName: 'Bob Wilson' });
|
||||
return Result.ok(undefined);
|
||||
}),
|
||||
};
|
||||
@@ -183,14 +183,14 @@ describe('AuthService', () => {
|
||||
|
||||
await expect(service.loginWithEmail({ email: 'e3', password: 'p3' } as any)).resolves.toEqual({
|
||||
token: 't3',
|
||||
user: { userId: 'u3', email: 'e3', displayName: 'd3' },
|
||||
user: { userId: 'u3', email: 'e3', displayName: 'Bob Wilson' },
|
||||
});
|
||||
|
||||
expect(loginUseCase.execute).toHaveBeenCalledWith({ email: 'e3', password: 'p3' });
|
||||
expect(identitySessionPort.createSession).toHaveBeenCalledWith(
|
||||
{
|
||||
id: 'u3',
|
||||
displayName: 'd3',
|
||||
displayName: 'Bob Wilson',
|
||||
email: 'e3',
|
||||
},
|
||||
undefined
|
||||
|
||||
@@ -40,7 +40,7 @@ describe('Auth session (HTTP, inmemory)', () => {
|
||||
|
||||
const signupRes = await agent
|
||||
.post('/auth/signup')
|
||||
.send({ email: 'u1@gridpilot.local', password: 'pw1', displayName: 'User 1' })
|
||||
.send({ email: 'u1@gridpilot.local', password: 'Password123!', displayName: 'John Smith' })
|
||||
.expect(201);
|
||||
|
||||
const setCookie = signupRes.headers['set-cookie'] as string[] | undefined;
|
||||
@@ -52,7 +52,7 @@ describe('Auth session (HTTP, inmemory)', () => {
|
||||
token: expect.stringMatching(/^gp_/),
|
||||
user: {
|
||||
email: 'u1@gridpilot.local',
|
||||
displayName: 'User 1',
|
||||
displayName: 'John Smith',
|
||||
userId: expect.any(String),
|
||||
},
|
||||
});
|
||||
@@ -75,7 +75,7 @@ describe('Auth session (HTTP, inmemory)', () => {
|
||||
user: {
|
||||
userId: 'driver-1',
|
||||
email: 'admin@gridpilot.local',
|
||||
displayName: 'Admin',
|
||||
displayName: 'Alex Martinez',
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ describe('AuthSessionPresenter', () => {
|
||||
it('maps user result into response model', () => {
|
||||
const user = User.create({
|
||||
id: UserId.fromString('user-1'),
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
email: 'user@example.com',
|
||||
passwordHash: PasswordHash.fromHash('hash'),
|
||||
});
|
||||
@@ -24,13 +24,13 @@ describe('AuthSessionPresenter', () => {
|
||||
expect(presenter.getResponseModel()).toEqual({
|
||||
userId: 'user-1',
|
||||
email: 'user@example.com',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
});
|
||||
|
||||
expect(presenter.responseModel).toEqual({
|
||||
userId: 'user-1',
|
||||
email: 'user@example.com',
|
||||
displayName: 'Test User',
|
||||
displayName: 'John Smith',
|
||||
});
|
||||
});
|
||||
|
||||
@@ -42,7 +42,7 @@ describe('AuthSessionPresenter', () => {
|
||||
it('reset clears model', () => {
|
||||
const user = User.create({
|
||||
id: UserId.fromString('user-1'),
|
||||
displayName: 'Test User',
|
||||
displayName: 'Jane Doe',
|
||||
email: 'user@example.com',
|
||||
passwordHash: PasswordHash.fromHash('hash'),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user