test: 测试用例

This commit is contained in:
Wxw-Gu
2026-09-20 15:56:27 +08:00
parent 9593ca0f54
commit 5036639aa1
6 changed files with 39 additions and 17 deletions
@@ -80,8 +80,10 @@ function makeHarness(options: { messages?: chat.FormattedMessage[] } = {}): Harn
available: true,
engine: 'windows-system-ocr',
platform: 'win32',
arch: 'x64',
runtimeVersion: '1.2.0',
language: 'zh-Hans-CN'
language: 'zh-Hans-CN',
message: ''
}),
recognize: async () => ({ success: true, text: '', language: 'zh-Hans-CN' })
})
@@ -151,9 +153,11 @@ describe('增量判据:水位不得漏掉新图片', () => {
listImageMessages,
countConversationImages: async (
_conversationId: string,
window?: { sinceMs?: number; beforeMs?: number }
range?: number | { sinceMs?: number; beforeMs?: number }
) => ({
count: state.messages.filter((message) => inWindow(message, window)).length,
count: state.messages.filter((message) =>
inWindow(message, typeof range === 'number' ? undefined : range)
).length,
typeColumn: 'local_type'
}),
...(options.withWatermark === false
@@ -165,8 +169,10 @@ describe('增量判据:水位不得漏掉新图片', () => {
available: true,
engine: 'windows-system-ocr',
platform: 'win32',
arch: 'x64',
runtimeVersion: '1.2.0',
language: 'zh-Hans-CN'
language: 'zh-Hans-CN',
message: ''
}),
recognize: async () => ({ success: true, text: '', language: 'zh-Hans-CN' })
})
@@ -359,10 +365,14 @@ describe('查询层:覆盖度必须是独立维度且带零结果诚实性', (
empty: 0,
missing: 0,
failed: 0,
runtimeUnavailable: 0,
pending: 0,
established: false,
complete: false,
systemicFailure: false,
countedAt: null,
tiers: [],
coveredToMs: null,
...input
})
@@ -64,6 +64,8 @@ function coverageOf(overrides: Partial<ImageTextIndexCoverage>): ImageTextIndexC
complete: false,
systemicFailure: false,
countedAt: null,
tiers: [],
coveredToMs: null,
...overrides
}
}
@@ -189,8 +191,10 @@ describe('前置依赖缺失时一条记录都不写', () => {
available: true,
engine: 'windows-system-ocr',
platform: 'win32',
arch: 'x64',
runtimeVersion: '1.2.0',
language: 'zh-Hans-CN'
language: 'zh-Hans-CN',
message: ''
}),
// 关键:解密服务缺失是**运行时**问题,不能落成每张图的"解密失败"
decryptService: () => null
@@ -114,11 +114,14 @@ function createHarness(): Harness {
listContacts: async () => [
{ md5: CONVERSATION, m_nsUsrName: 'boundary', type: 'user' as const }
],
// 参数必须是 `number | {…}`——与 ImageMessageCountProbe 的签名保持一致。
countConversationImages: async (
_conversationId: string,
window?: { sinceMs?: number; beforeMs?: number }
range?: number | { sinceMs?: number; beforeMs?: number }
) => ({
count: imagesOnly.filter((message) => inWindow(message, window)).length,
count: imagesOnly.filter((message) =>
inWindow(message, typeof range === 'number' ? undefined : range)
).length,
typeColumn: 'local_type'
}),
imageWatermark: async () => ({ count: IMAGE_COUNT, maxLocalId: TEXT_COUNT + IMAGE_COUNT }),
@@ -128,8 +131,10 @@ function createHarness(): Harness {
available: true,
engine: 'macos-system-ocr',
platform: 'darwin',
arch: 'arm64',
runtimeVersion: '1.2.0',
language: null
language: null,
message: ''
}),
decryptService: () =>
({
@@ -131,8 +131,11 @@ function makeHarness(options: {
],
listImageMessages,
// 窗口感知的计数:新架构"这段没图片就整段跳过"完全依赖它说实话。
countConversationImages: async (_conversationId: string, window?: Window) => ({
count: state.messages.filter((message) => inWindow(message, window)).length,
// 参数必须是 `number | Window`——与 ImageMessageCountProbe 的签名保持一致。
countConversationImages: async (_conversationId: string, range?: number | Window) => ({
count: state.messages.filter((message) =>
inWindow(message, typeof range === 'number' ? undefined : range)
).length,
typeColumn: 'local_type'
}),
imageWatermark: async () => ({ count: state.count, maxLocalId: state.maxLocalId }),
@@ -142,8 +145,10 @@ function makeHarness(options: {
available: true,
engine: 'windows-system-ocr',
platform: 'win32',
arch: 'x64',
runtimeVersion: '1.2.0',
language: 'zh-Hans-CN'
language: 'zh-Hans-CN',
message: ''
}),
recognize: async () => ({ success: true, text: '', language: 'zh-Hans-CN' })
})
@@ -82,7 +82,6 @@ import {
/** 与真实派生库同形:binding 主键 = `sourceMessageId(message)` = `local:<localId>`。 */
const SELF_KEY = 'local:9001'
const OTHER_KEY = 'local:9002'
function coverage(overrides: Partial<ImageTextIndexCoverage> = {}): ImageTextIndexCoverage {
return {
@@ -98,6 +97,8 @@ function coverage(overrides: Partial<ImageTextIndexCoverage> = {}): ImageTextInd
complete: true,
systemicFailure: false,
countedAt: Date.parse('2026-09-16T09:00:00+08:00'),
tiers: [],
coveredToMs: null,
...overrides
}
}
+2 -5
View File
@@ -1,6 +1,6 @@
{
"note": "测试文件类型检查基线:只允许下降,不允许上升。用 node scripts/typecheck-tests.cjs --update 下调。",
"total": 240,
"total": 234,
"files": {
"tests/component/ai-model-settings.test.tsx": 2,
"tests/component/ai-search-cache-consent.test.tsx": 3,
@@ -24,16 +24,13 @@
"tests/e2e/report-template-market.spec.ts": 1,
"tests/e2e/report-template-render.spec.ts": 1,
"tests/integration/export-media-flow.test.ts": 3,
"tests/integration/image-text-index-checkpoint-and-coverage.test.ts": 3,
"tests/integration/image-text-index-concurrency.test.ts": 4,
"tests/integration/image-text-index-coverage-honesty.test.ts": 1,
"tests/integration/image-text-index-image-query.test.ts": 1,
"tests/integration/image-text-index-incremental-repair.test.ts": 4,
"tests/integration/image-text-index-knowledge-invalidation.test.ts": 3,
"tests/integration/image-text-index-progress-notify.test.ts": 1,
"tests/integration/image-text-index-store-cache.test.ts": 1,
"tests/integration/image-text-index-synthetic-e2e.test.ts": 22,
"tests/integration/query-agent-image-ocr-text.test.ts": 17,
"tests/integration/query-agent-image-ocr-text.test.ts": 16,
"tests/integration/query-agent-self-direction.test.ts": 7,
"tests/integration/scheduled-report-api.test.ts": 3,
"tests/unit/agent-hub-routing.test.ts": 1,