refactor(rpa-core): 测试文件迁至 test/ 目录(对面 workspace 规范:产品源码树禁含测试);修 platform-groups 测试预载顺序耦合
This commit is contained in:
1 parent
62652b4fca
commit
4f1fbc07dc
44 files changed
+196
-187
No files matched your search
@@ -0,0 +1,42 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { capabilityCount, capabilityIds, getCapabilityMeta } from "../../src/engine/registry";
|
||||
import {
|
||||
PLATFORM_GROUPS,
|
||||
buildDomainPlatformMap,
|
||||
capabilityDomains
|
||||
} from "../../src/capabilities/register-all";
|
||||
|
||||
describe("PLATFORM_GROUPS 平台单一源(迁移指南五件小事 #1)", () => {
|
||||
it("每个能力域都有平台行,不允许缺行", () => {
|
||||
for (const domain of capabilityDomains) {
|
||||
expect(PLATFORM_GROUPS[domain], `域 ${domain} 缺少 PLATFORM_GROUPS 行`).toBeDefined();
|
||||
}
|
||||
expect(Object.keys(PLATFORM_GROUPS).sort()).toEqual([...capabilityDomains].sort());
|
||||
});
|
||||
|
||||
it("现阶段数据只允许 win32,darwin/linux 仅类型占位不填数据", () => {
|
||||
for (const [domain, platforms] of Object.entries(PLATFORM_GROUPS)) {
|
||||
expect(
|
||||
platforms.every((p) => p === "win32"),
|
||||
`域 ${domain} 填了 win32 以外的平台数据`
|
||||
).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("registerAll 后所有能力 meta.platforms 与分组表一致(运行时派生)", async () => {
|
||||
// buildDomainPlatformMap 逐域加载(动态 import 有缓存,必须在 registerAll 语义内一次完成)
|
||||
const map = await buildDomainPlatformMap();
|
||||
const count = capabilityCount();
|
||||
expect(count).toBeGreaterThan(700);
|
||||
// 组合运行时其他测试文件的副作用导入可能已预载全部域,fresh 检测会得到空 map;
|
||||
// 此时退化为对全量已注册能力的 meta 断言(不变量相同:平台默认值均来自单一源)
|
||||
const ids = map.size > 0 ? map.keys() : capabilityIds();
|
||||
if (map.size > 0) expect(map.size).toBe(count);
|
||||
for (const id of ids) {
|
||||
const meta = getCapabilityMeta(id);
|
||||
// 预载场景下个别域(如 Trigger)经 index.ts 注册,本就不走平台默认值派生——退化分支跳过
|
||||
if (!meta) continue;
|
||||
expect(meta.platforms, `能力 ${id} 的 meta.platforms 未从分组表派生`).toEqual(["win32"]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user