forked from hangshuo652/aurak
fix: code review — 7 issues resolved
(C1) Add dimensionScores/radarData/passed columns to AssessmentSession (C2) Mock DataSource in service.spec.ts + app.e2e-spec.ts (C3) Mock AuditLogService in controller.spec.ts (C4) Rewrite deleteSession tests for dataSource.transaction (I1) batchDeleteSessions uses transaction with certificate cleanup (I2) extractDimensionScores reads from session property (I3/I5) PDF generator supports multi-page + newline splitting (I4) findOne inside transaction uses deleteCondition
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { getRepositoryToken } from '@nestjs/typeorm';
|
||||
import { DataSource } from 'typeorm';
|
||||
import { AssessmentService } from '../src/assessment/assessment.service';
|
||||
import { AssessmentSession } from '../src/assessment/entities/assessment-session.entity';
|
||||
import { AssessmentQuestion } from '../src/assessment/entities/assessment-question.entity';
|
||||
@@ -20,6 +21,16 @@ import { ChatService } from '../src/chat/chat.service';
|
||||
import { I18nService } from '../src/i18n/i18n.service';
|
||||
import { TenantService } from '../src/tenant/tenant.service';
|
||||
|
||||
const mockManager = () => ({
|
||||
findOne: jest.fn(),
|
||||
delete: jest.fn().mockResolvedValue({ affected: 1 }),
|
||||
save: jest.fn(),
|
||||
});
|
||||
|
||||
const mockDataSource = () => ({
|
||||
transaction: jest.fn(async (cb: any) => cb(mockManager())),
|
||||
});
|
||||
|
||||
/**
|
||||
* Certificate integration tests — verify the full certificate lifecycle
|
||||
* through the AssessmentService with mocked repositories.
|
||||
@@ -61,6 +72,7 @@ describe('Certificate (integration)', () => {
|
||||
{ provide: ChatService, useFactory: mockSvc },
|
||||
{ provide: I18nService, useFactory: mockSvc },
|
||||
{ provide: TenantService, useFactory: mockSvc },
|
||||
{ provide: DataSource, useFactory: mockDataSource },
|
||||
],
|
||||
}).compile();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user