website refactor
This commit is contained in:
@@ -15,7 +15,7 @@ import { FeatureAvailabilityGuard } from '../policy/FeatureAvailabilityGuard';
|
||||
describe('Analytics domain (HTTP, module-wiring)', () => {
|
||||
const originalEnv = { ...process.env };
|
||||
|
||||
let app: any;
|
||||
let app: import("@nestjs/common").INestApplication;
|
||||
|
||||
beforeAll(async () => {
|
||||
vi.resetModules();
|
||||
@@ -62,9 +62,9 @@ describe('Analytics domain (HTTP, module-wiring)', () => {
|
||||
};
|
||||
|
||||
app.useGlobalGuards(
|
||||
new AuthenticationGuard(sessionPort as any),
|
||||
new AuthorizationGuard(reflector, authorizationService as any),
|
||||
new FeatureAvailabilityGuard(reflector, policyService as any),
|
||||
new AuthenticationGuard(sessionPort as never),
|
||||
new AuthorizationGuard(reflector, authorizationService as never),
|
||||
new FeatureAvailabilityGuard(reflector, policyService as never),
|
||||
);
|
||||
|
||||
await app.init();
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('AnalyticsController', () => {
|
||||
recordEngagement: vi.fn(),
|
||||
getDashboardData: vi.fn(),
|
||||
getAnalyticsMetrics: vi.fn(),
|
||||
} as any;
|
||||
} as never;
|
||||
controller = new AnalyticsController(service);
|
||||
});
|
||||
|
||||
@@ -121,7 +121,7 @@ describe('AnalyticsController', () => {
|
||||
});
|
||||
|
||||
describe('auth guards (HTTP)', () => {
|
||||
let app: any;
|
||||
let app: import("@nestjs/common").INestApplication;
|
||||
|
||||
const sessionPort: { getCurrentSession: () => Promise<null | { token: string; user: { id: string } }> } = {
|
||||
getCurrentSession: vi.fn(async () => null),
|
||||
@@ -168,9 +168,9 @@ describe('AnalyticsController', () => {
|
||||
|
||||
const reflector = new Reflector();
|
||||
app.useGlobalGuards(
|
||||
new AuthenticationGuard(sessionPort as any),
|
||||
new AuthorizationGuard(reflector, authorizationService as any),
|
||||
new FeatureAvailabilityGuard(reflector, policyService as any),
|
||||
new AuthenticationGuard(sessionPort as never),
|
||||
new AuthorizationGuard(reflector, authorizationService as never),
|
||||
new FeatureAvailabilityGuard(reflector, policyService as never),
|
||||
);
|
||||
|
||||
await app.init();
|
||||
|
||||
@@ -17,10 +17,10 @@ describe('AnalyticsService', () => {
|
||||
};
|
||||
|
||||
const service = new AnalyticsService(
|
||||
recordPageViewUseCase as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
recordPageViewUseCase as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
recordPageViewPresenter,
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -28,9 +28,9 @@ describe('AnalyticsService', () => {
|
||||
);
|
||||
|
||||
const dto = await service.recordPageView({
|
||||
entityType: 'league' as any,
|
||||
entityType: 'league' as never,
|
||||
entityId: 'l1',
|
||||
visitorType: 'anonymous' as any,
|
||||
visitorType: 'anonymous' as never,
|
||||
sessionId: 's1',
|
||||
});
|
||||
|
||||
@@ -40,10 +40,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('recordPageView throws on use case error', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'nope' } })) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'nope' } })) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -51,16 +51,16 @@ describe('AnalyticsService', () => {
|
||||
);
|
||||
|
||||
await expect(
|
||||
service.recordPageView({ entityType: 'league' as any, entityId: 'l1', visitorType: 'anonymous' as any, sessionId: 's1' }),
|
||||
service.recordPageView({ entityType: 'league' as never, entityId: 'l1', visitorType: 'anonymous' as never, sessionId: 's1' }),
|
||||
).rejects.toThrow('nope');
|
||||
});
|
||||
|
||||
it('recordPageView throws with fallback message when no details.message', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as any)) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as never)) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -68,7 +68,7 @@ describe('AnalyticsService', () => {
|
||||
);
|
||||
|
||||
await expect(
|
||||
service.recordPageView({ entityType: 'league' as any, entityId: 'l1', visitorType: 'anonymous' as any, sessionId: 's1' }),
|
||||
service.recordPageView({ entityType: 'league' as never, entityId: 'l1', visitorType: 'anonymous' as never, sessionId: 's1' }),
|
||||
).rejects.toThrow('Failed to record page view');
|
||||
});
|
||||
|
||||
@@ -81,10 +81,10 @@ describe('AnalyticsService', () => {
|
||||
};
|
||||
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
recordEngagementUseCase as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
recordEngagementUseCase as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
recordEngagementPresenter,
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -92,8 +92,8 @@ describe('AnalyticsService', () => {
|
||||
);
|
||||
|
||||
const dto = await service.recordEngagement({
|
||||
action: 'click' as any,
|
||||
entityType: 'league' as any,
|
||||
action: 'click' as never,
|
||||
entityType: 'league' as never,
|
||||
entityId: 'l1',
|
||||
actorType: 'anonymous',
|
||||
sessionId: 's1',
|
||||
@@ -104,10 +104,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('recordEngagement throws with details message on error', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'nope' } })) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'nope' } })) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -116,8 +116,8 @@ describe('AnalyticsService', () => {
|
||||
|
||||
await expect(
|
||||
service.recordEngagement({
|
||||
action: 'click' as any,
|
||||
entityType: 'league' as any,
|
||||
action: 'click' as never,
|
||||
entityType: 'league' as never,
|
||||
entityId: 'l1',
|
||||
actorType: 'anonymous',
|
||||
sessionId: 's1',
|
||||
@@ -127,10 +127,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('recordEngagement throws with fallback message when no details.message', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as any)) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as never)) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -139,8 +139,8 @@ describe('AnalyticsService', () => {
|
||||
|
||||
await expect(
|
||||
service.recordEngagement({
|
||||
action: 'click' as any,
|
||||
entityType: 'league' as any,
|
||||
action: 'click' as never,
|
||||
entityType: 'league' as never,
|
||||
entityId: 'l1',
|
||||
actorType: 'anonymous',
|
||||
sessionId: 's1',
|
||||
@@ -162,10 +162,10 @@ describe('AnalyticsService', () => {
|
||||
};
|
||||
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
getDashboardDataUseCase as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
getDashboardDataUseCase as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
getDashboardDataPresenter,
|
||||
@@ -182,10 +182,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('getDashboardData throws with details message on error', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'boom' } })) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'boom' } })) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -197,10 +197,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('getDashboardData throws with fallback message when no details.message', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as any)) } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as never)) } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -224,10 +224,10 @@ describe('AnalyticsService', () => {
|
||||
};
|
||||
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
getAnalyticsMetricsUseCase as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
getAnalyticsMetricsUseCase as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -244,10 +244,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('getAnalyticsMetrics throws with details message on error', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'boom' } })) } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR', details: { message: 'boom' } })) } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
@@ -259,10 +259,10 @@ describe('AnalyticsService', () => {
|
||||
|
||||
it('getAnalyticsMetrics throws with fallback message when no details.message', async () => {
|
||||
const service = new AnalyticsService(
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn() } as any,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as any)) } as any,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn() } as never,
|
||||
{ execute: vi.fn(async () => Result.err({ code: 'REPOSITORY_ERROR' } as never)) } as never,
|
||||
new RecordPageViewPresenter(),
|
||||
new RecordEngagementPresenter(),
|
||||
new GetDashboardDataPresenter(),
|
||||
|
||||
Reference in New Issue
Block a user