Files
UHD_Media_Tool/apps/server/vitest.config.ts
T
rootandClaude Opus 5.5 1db689d9a7 feat: 生命周期广播事件与链式钩子设施(ADR-006)
- contracts:补齐生命周期广播事件(订阅、下载、整理结束、刮削、字幕、作品关注 / 元数据 / 季集结构、站点可达性)
  的类型与 payload schema,LIFECYCLE_EVENTS 清单与 lifecycleKey 幂等键;HOOK_POINTS 链式钩子挂点;
  FEATURES 功能清单与 SLOT_POSITIONS 前端插槽位置
- outbox 中继支持一条事件路由给多个订阅方(其余订阅方用 <键>#<任务名>);生命周期事件允许多模块订阅,
  没有订阅方时也被中继认领并镜像到 SSE
- 服务端 HookRegistry:按注册顺序执行、rewrite / intercept 两类、单钩子超时与异常隔离、无注册零开销;
  ServerModule 增加 manifest 与 registerHooks,bootstrap 装配 ctx.hooks
- ADR-006 与 server README「如何写一个功能模块」

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Cxwgnn2pbzQ7rXv3rq7fei
2026-10-06 19:27:02 +08:00

78 lines
2.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { defineConfig } from "vitest/config";
// 三组测试,按 groupOrder 依次跑:
// unit —— 纯内存、无 PG,文件并行;
// pg —— 真实 PG、假引擎(每文件独立 schema),文件并行;
// serial —— 起真实引擎 / worker / 后台循环 / 子进程的集成与 e2e,文件级串行。并发跑时 worker、轮询、迁移
// 互相抢 CPU 与连接,会把"入库→状态推进"这类时序拉长到超时,串行让每个文件拿到稳定的时序预算。
// 新测试缺省进 pg;起真实 worker / 引擎 / 子进程的加进 SERIAL;确认不碰 PG 的加进 UNIT。
// 并行文件数受开发库连接数约束(max_connections 100,每个 harness 连接池 5–10):MAX_WORKERS 别随手调大。
const UNIT = [
"test/api-registry.test.ts",
"test/organize-in-place-verify.test.ts",
"test/file-manager/preview-parse.test.ts",
"test/search/work-match.test.ts",
"test/auth.test.ts",
"test/health.test.ts",
"test/hooks/hook-registry.test.ts",
"test/hooks/resource-selection.test.ts",
"test/sources-identity/identity-differential.test.ts",
"test/sources-identity/enrich-sources.test.ts",
"test/invoke-limits.test.ts",
"test/logger.test.ts",
"test/mapping-compat.test.ts",
"test/modules.test.ts",
"test/sse.test.ts",
"test/static.test.ts",
"test/system-resources.test.ts",
];
const SERIAL = [
// 起真实沙箱子进程(内存 / 超时强杀)
"test/sandbox/**",
"test/e2e/**/*.test.ts",
"test/auth-settings/admin-api.test.ts",
"test/auth-settings/engine-retry.test.ts",
"test/auth-settings/sse-pg.test.ts",
"test/system/**/*.test.ts",
"test/search/search.test.ts",
"test/search/two-stage-search.test.ts",
"test/worker-lanes.test.ts",
"test/preflight.test.ts",
"test/bootstrap.test.ts",
];
const MAX_WORKERS = 6;
export default defineConfig({
test: {
// 建/删 schema 在一把咨询锁上排队(withSchemaLock),迁移 + 引擎 schema 在负载下可能超过缺省 10s
hookTimeout: 120_000,
teardownTimeout: 60_000,
maxWorkers: MAX_WORKERS,
projects: [
{ extends: true, test: { name: "unit", include: UNIT } },
{
extends: true,
test: {
name: "pg",
include: ["test/**/*.test.ts"],
exclude: [...UNIT, ...SERIAL],
// 迁移类用例在用例体里建 schema + 迁移,并行时排队等同一把锁,缺省 5s 不够
testTimeout: 60_000,
sequence: { groupOrder: 1 },
},
},
{
extends: true,
test: {
name: "serial",
include: SERIAL,
fileParallelism: false,
sequence: { groupOrder: 2 },
},
},
],
},
});