test(backend): fix all typescript compiler type errors in test suites
This commit is contained in:
+7
-3
@@ -1,5 +1,6 @@
|
||||
// File: src/modules/ai/intent-classifier/controllers/intent-admin.controller.spec.ts
|
||||
// Change Log
|
||||
// - 2026-05-21: แก้ไขไทป์ให้ตรงกับ Enum ล่าสุด
|
||||
// - 2026-05-19: สร้าง Integration test สำหรับ Admin API (T016, US1).
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
@@ -10,7 +11,10 @@ import {
|
||||
} from './intent-admin.controller';
|
||||
import { IntentDefinitionService } from '../services/intent-definition.service';
|
||||
import { IntentPatternService } from '../services/intent-pattern.service';
|
||||
import { IntentCategory } from '../interfaces/intent-category.enum';
|
||||
import {
|
||||
IntentCategory,
|
||||
PatternType,
|
||||
} from '../interfaces/intent-category.enum';
|
||||
import { JwtAuthGuard } from '../../../../common/guards/jwt-auth.guard';
|
||||
import { RbacGuard } from '../../../../common/guards/rbac.guard';
|
||||
|
||||
@@ -60,7 +64,7 @@ describe('IntentAdminController', () => {
|
||||
|
||||
describe('findAll', () => {
|
||||
it('ควรเรียก service.findAll พร้อม filter', async () => {
|
||||
await controller.findAll('read', 'true');
|
||||
await controller.findAll(IntentCategory.READ, 'true');
|
||||
|
||||
expect(definitionService.findAll).toHaveBeenCalledWith({
|
||||
category: 'read',
|
||||
@@ -135,7 +139,7 @@ describe('IntentAdminController', () => {
|
||||
|
||||
describe('createPattern', () => {
|
||||
it('ควร merge intentCode กับ dto', async () => {
|
||||
const dto = { patternType: 'keyword' as const, patternValue: 'rfa' };
|
||||
const dto = { patternType: PatternType.KEYWORD, patternValue: 'rfa' };
|
||||
patternService.create.mockResolvedValue({ publicId: 'p-1' } as never);
|
||||
|
||||
await controller.createPattern('GET_RFA', dto);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// File: src/modules/ai/intent-classifier/services/intent-analytics.service.spec.ts
|
||||
// Change Log
|
||||
// - 2026-05-21: แก้ไขการทำ Type Casting ของ AiAuditLog ใน Mock ให้สมบูรณ์ขึ้นด้วย unknown
|
||||
// - 2026-05-19: สร้าง Unit tests สำหรับ IntentAnalyticsService (T033, US3).
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
@@ -21,6 +22,7 @@ function mockLog(
|
||||
const intentCode = overrides.intentCode ?? 'GET_RFA';
|
||||
return {
|
||||
id: Math.floor(Math.random() * 1000),
|
||||
publicId: 'mock-public-id',
|
||||
aiModel: 'intent-classifier',
|
||||
modelName: method === 'llm_fallback' ? 'gemma4:e4b' : 'pattern-match',
|
||||
aiSuggestionJson: {
|
||||
@@ -33,7 +35,7 @@ function mockLog(
|
||||
confidenceScore: overrides.confidence ?? 1.0,
|
||||
status: overrides.status ?? AiAuditStatus.SUCCESS,
|
||||
createdAt: new Date(),
|
||||
} as AiAuditLog;
|
||||
} as unknown as AiAuditLog;
|
||||
}
|
||||
|
||||
describe('IntentAnalyticsService', () => {
|
||||
|
||||
Reference in New Issue
Block a user