test(backend): fix all typescript compiler type errors in test suites
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// File: backend/tests/e2e/rfa-workflow.e2e-spec.ts
|
||||
// Change Log
|
||||
// - 2026-05-21: แก้ไขไทป์ Record ให้ครอบคลุม ReviewTaskStatus ทั้งหมด (EXPIRED, CANCELLED)
|
||||
// - 2026-05-15: Initial E2E test scaffolding
|
||||
// - 2026-05-16: Simplified to use unit test approach - full E2E requires database
|
||||
// - Note: Full E2E tests require running database and full infrastructure setup
|
||||
@@ -37,6 +38,8 @@ describe('RFA Approval Workflow (E2E)', () => {
|
||||
],
|
||||
[ReviewTaskStatus.COMPLETED]: [],
|
||||
[ReviewTaskStatus.DELEGATED]: [ReviewTaskStatus.IN_PROGRESS],
|
||||
[ReviewTaskStatus.EXPIRED]: [],
|
||||
[ReviewTaskStatus.CANCELLED]: [],
|
||||
};
|
||||
|
||||
// Verify status enum values exist
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// File: backend/tests/integration/cross-spec/qdrant-isolation.spec.ts
|
||||
// Change Log:
|
||||
// - 2026-05-21: แก้ไข Type Casting ของ AiQdrantService ด้วย unknown
|
||||
// - 2026-05-16: Cross-spec integration test for QdrantService projectPublicId isolation
|
||||
// - 2026-05-16: Fixed mocking strategy to use factory pattern with proper method exposure
|
||||
|
||||
@@ -132,7 +133,9 @@ describe('Cross-Spec: QdrantService Isolation', () => {
|
||||
|
||||
it('should verify no rawSearch method exists (security)', () => {
|
||||
// Assert: No rawSearch method that bypasses projectPublicId filtering
|
||||
expect((service as Record<string, unknown>).rawSearch).toBeUndefined();
|
||||
expect(
|
||||
(service as unknown as Record<string, unknown>).rawSearch
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it('should handle RFA cross-spec usage correctly', async () => {
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
// File: backend/tests/performance/approval-matrix.perf-spec.ts
|
||||
// Change Log:
|
||||
// - 2026-05-21: แก้ไขการจำลองข้อมูลและการคอมไพล์ไทป์ใน ResponseCodeRule
|
||||
// - 2026-05-16: Performance test for Approval Matrix Service with 1000+ rules
|
||||
|
||||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
@@ -46,20 +47,25 @@ describe('ApprovalMatrixService Performance', () => {
|
||||
(_, i) => ({
|
||||
id: i + 1,
|
||||
responseCodeId: (i % 10) + 1,
|
||||
documentTypeId: (i % 5) + 1,
|
||||
documentTypeId: 1,
|
||||
isRequired: i % 3 === 0,
|
||||
priority: (i % 5) + 1,
|
||||
responseCode: {
|
||||
id: (i % 10) + 1,
|
||||
code: `CODE-${i % 10}`,
|
||||
isActive: true,
|
||||
} as unknown as ResponseCode,
|
||||
})
|
||||
);
|
||||
|
||||
jest.spyOn(responseCodeRepo, 'find').mockResolvedValue([]);
|
||||
jest
|
||||
.spyOn(responseCodeRepo, 'find')
|
||||
.spyOn(responseCodeRuleRepo, 'find')
|
||||
.mockResolvedValue(mockRules as ResponseCodeRule[]);
|
||||
jest.spyOn(responseCodeRuleRepo, 'find').mockResolvedValue([]);
|
||||
|
||||
// Act: Measure lookup time
|
||||
const startTime = Date.now();
|
||||
const _result = await service.findByDocumentType(1, 'SHOP_DRAWING');
|
||||
const _result = await service.findByDocumentType(1, 100);
|
||||
const endTime = Date.now();
|
||||
|
||||
// Assert: Must complete within 100ms
|
||||
@@ -81,19 +87,26 @@ describe('ApprovalMatrixService Performance', () => {
|
||||
category: (
|
||||
['ENGINEERING', 'CONTRACT', 'QUALITY'] as ResponseCodeCategory[]
|
||||
)[i % 3],
|
||||
description: `Description for code ${i}`,
|
||||
descriptionTh: `Description for code ${i}`,
|
||||
})
|
||||
);
|
||||
|
||||
const mockRules: Partial<ResponseCodeRule>[] = mockCodes.map((code, i) => ({
|
||||
id: i + 1,
|
||||
responseCodeId: code.id,
|
||||
documentTypeId: 1,
|
||||
responseCode: code as ResponseCode,
|
||||
}));
|
||||
|
||||
jest.spyOn(responseCodeRepo, 'find').mockResolvedValue([]);
|
||||
jest
|
||||
.spyOn(responseCodeRepo, 'find')
|
||||
.mockResolvedValue(mockCodes as ResponseCode[]);
|
||||
jest.spyOn(responseCodeRuleRepo, 'find').mockResolvedValue([]);
|
||||
.spyOn(responseCodeRuleRepo, 'find')
|
||||
.mockResolvedValue(mockRules as ResponseCodeRule[]);
|
||||
|
||||
// Act: Run 10 concurrent lookups
|
||||
const startTime = Date.now();
|
||||
const promises = Array.from({ length: 10 }, () =>
|
||||
service.findByDocumentType(1, 'SHOP_DRAWING')
|
||||
service.findByDocumentType(1, 100)
|
||||
);
|
||||
await Promise.all(promises);
|
||||
const endTime = Date.now();
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
// File: backend/tests/performance/review-tasks.perf-spec.ts
|
||||
// Change Log:
|
||||
// - 2026-05-21: แก้ไขไทป์ ReviewTaskStatus ในข้อมูลจำลองและสเปก
|
||||
// - 2026-05-16: Performance test for Review Tasks Query with 10,000+ tasks
|
||||
|
||||
import { ReviewTask } from '../../src/modules/review-team/entities/review-task.entity';
|
||||
import { ReviewTaskStatus } from '../../src/modules/common/enums/review.enums';
|
||||
|
||||
interface FindAllOptions {
|
||||
status?: string;
|
||||
status?: ReviewTaskStatus;
|
||||
assignedToUserId?: number;
|
||||
disciplineId?: number;
|
||||
page?: number;
|
||||
@@ -69,7 +71,11 @@ describe('ReviewTaskService Query Performance', () => {
|
||||
(_, i) => ({
|
||||
id: i + 1,
|
||||
uuid: `task-${i}`,
|
||||
status: ['PENDING', 'IN_PROGRESS', 'COMPLETED'][i % 3],
|
||||
status: [
|
||||
ReviewTaskStatus.PENDING,
|
||||
ReviewTaskStatus.IN_PROGRESS,
|
||||
ReviewTaskStatus.COMPLETED,
|
||||
][i % 3],
|
||||
assignedToUserId: (i % 100) + 1,
|
||||
rfaRevisionId: (i % 500) + 1,
|
||||
disciplineId: (i % 20) + 1,
|
||||
@@ -81,7 +87,7 @@ describe('ReviewTaskService Query Performance', () => {
|
||||
|
||||
const startTime = Date.now();
|
||||
const result = service.findAll({
|
||||
status: 'PENDING',
|
||||
status: ReviewTaskStatus.PENDING,
|
||||
page: 1,
|
||||
limit: 20,
|
||||
});
|
||||
@@ -99,7 +105,7 @@ describe('ReviewTaskService Query Performance', () => {
|
||||
(_, i) => ({
|
||||
id: i + 1,
|
||||
uuid: `task-${i}`,
|
||||
status: 'PENDING',
|
||||
status: ReviewTaskStatus.PENDING,
|
||||
assignedToUserId: 42,
|
||||
disciplineId: 5,
|
||||
})
|
||||
@@ -109,7 +115,7 @@ describe('ReviewTaskService Query Performance', () => {
|
||||
|
||||
const startTime = Date.now();
|
||||
const result = service.findAll({
|
||||
status: 'PENDING',
|
||||
status: ReviewTaskStatus.PENDING,
|
||||
assignedToUserId: 42,
|
||||
disciplineId: 5,
|
||||
page: 1,
|
||||
|
||||
Reference in New Issue
Block a user