fix issues in core
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import { GetCurrentUserSessionUseCase } from './GetCurrentUserSessionUseCase';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
|
||||
import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
|
||||
describe('GetCurrentUserSessionUseCase', () => {
|
||||
@@ -11,7 +10,7 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
clearSession: Mock;
|
||||
};
|
||||
let logger: Logger;
|
||||
let output: UseCaseOutputPort<AuthSessionDTO | null> & { present: Mock };
|
||||
let output: UseCaseOutputPort<AuthSession | null> & { present: Mock };
|
||||
let useCase: GetCurrentUserSessionUseCase;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -40,7 +39,7 @@ describe('GetCurrentUserSessionUseCase', () => {
|
||||
});
|
||||
|
||||
it('returns the current auth session when one exists', async () => {
|
||||
const session: AuthSessionDTO = {
|
||||
const session: AuthSession = {
|
||||
user: {
|
||||
id: 'user-1',
|
||||
email: 'test@example.com',
|
||||
|
||||
@@ -2,9 +2,8 @@ import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import { HandleAuthCallbackUseCase } from './HandleAuthCallbackUseCase';
|
||||
import type { IdentityProviderPort } from '../ports/IdentityProviderPort';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { AuthCallbackCommandDTO } from '../dto/AuthCallbackCommandDTO';
|
||||
import type { AuthenticatedUserDTO } from '../dto/AuthenticatedUserDTO';
|
||||
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
|
||||
import type { AuthCallbackCommand, AuthenticatedUser } from '../ports/IdentityProviderPort';
|
||||
import type { AuthSession } from '../ports/IdentitySessionPort';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
|
||||
describe('HandleAuthCallbackUseCase', () => {
|
||||
@@ -17,7 +16,7 @@ describe('HandleAuthCallbackUseCase', () => {
|
||||
clearSession: Mock;
|
||||
};
|
||||
let logger: Logger;
|
||||
let output: UseCaseOutputPort<AuthSessionDTO> & { present: Mock };
|
||||
let output: UseCaseOutputPort<AuthSession> & { present: Mock };
|
||||
let useCase: HandleAuthCallbackUseCase;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -48,20 +47,20 @@ describe('HandleAuthCallbackUseCase', () => {
|
||||
});
|
||||
|
||||
it('completes auth and creates a session', async () => {
|
||||
const command: AuthCallbackCommandDTO = {
|
||||
const command: AuthCallbackCommand = {
|
||||
provider: 'IRACING_DEMO',
|
||||
code: 'auth-code',
|
||||
state: 'state-123',
|
||||
returnTo: 'https://app/callback',
|
||||
};
|
||||
|
||||
const user: AuthenticatedUserDTO = {
|
||||
const user: AuthenticatedUser = {
|
||||
id: 'user-1',
|
||||
email: 'test@example.com',
|
||||
displayName: 'Test User',
|
||||
};
|
||||
|
||||
const session: AuthSessionDTO = {
|
||||
const session: AuthSession = {
|
||||
user,
|
||||
issuedAt: Date.now(),
|
||||
expiresAt: Date.now() + 1000,
|
||||
|
||||
@@ -2,8 +2,7 @@ import { describe, it, expect, vi, type Mock } from 'vitest';
|
||||
import { SignupWithEmailUseCase } from './SignupWithEmailUseCase';
|
||||
import type { SignupWithEmailInput } from './SignupWithEmailUseCase';
|
||||
import type { IUserRepository, StoredUser } from '../../domain/repositories/IUserRepository';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { AuthSessionDTO } from '../dto/AuthSessionDTO';
|
||||
import type { AuthSession, IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import type { Logger, UseCaseOutputPort } from '@core/shared/application';
|
||||
|
||||
type SignupWithEmailOutput = unknown;
|
||||
@@ -58,7 +57,7 @@ describe('SignupWithEmailUseCase', () => {
|
||||
|
||||
userRepository.findByEmail.mockResolvedValue(null);
|
||||
|
||||
const session: AuthSessionDTO = {
|
||||
const session: AuthSession = {
|
||||
user: {
|
||||
id: 'user-1',
|
||||
email: command.email.toLowerCase(),
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import type { IUserRepository, StoredUser } from '../../domain/repositories/IUserRepository';
|
||||
import type { AuthenticatedUserDTO } from '../dto/AuthenticatedUserDTO';
|
||||
import type { AuthenticatedUser } from '../ports/IdentityProviderPort';
|
||||
import type { IdentitySessionPort } from '../ports/IdentitySessionPort';
|
||||
import { Result } from '@core/shared/application/Result';
|
||||
import type { ApplicationErrorCode } from '@core/shared/errors/ApplicationErrorCode';
|
||||
@@ -103,7 +103,7 @@ export class SignupWithEmailUseCase {
|
||||
await this.userRepository.create(newUser);
|
||||
|
||||
// Create session
|
||||
const authenticatedUser: AuthenticatedUserDTO = {
|
||||
const authenticatedUser: AuthenticatedUser = {
|
||||
id: newUser.id,
|
||||
displayName: newUser.displayName,
|
||||
email: newUser.email,
|
||||
|
||||
Reference in New Issue
Block a user