迁移前置项(指南五件小事 #1 + 第 0 步作业 #2): - register-all.ts 新增 PLATFORM_GROUPS 单一权威表(33 域全标 win32,darwin/linux 仅类型占位) - registerAll 逐域加载时把平台默认值落进 meta.platforms(能力显式声明优先); 新增 buildDomainPlatformMap 供构建脚本与运行时共用同一张表 - build-catalog.mjs 删除 WIN32_GROUPS 硬编码,platformTag 从包内分组表派生(改 tsx 运行) - 守卫测试 platform-groups.test.ts:域无缺行 / 不偷填非 win32 数据 / meta 派生一致 - catalog.json 重生成:687 个组件获得 platformTag=win32(此前从未生效) - 源数据恢复:对面重构删了 shizai-catalog-data.js,从其历史 commit 7bc627c8 恢复到 temp/catalog-source/(不入库)并作为回退路径 - catalog-overrides 增强 addFields 支持;把此前直接改 catalog.json 的 96 处假必填修正、 label 修正、Screenlock 字段清理、12 个实现读取但源数据缺失的字段全部沉淀进 overrides, 重生成后参数审计 A/B 类保持 0/0
38 行
1.5 KiB
TypeScript
38 行
1.5 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { capabilityCount, getCapabilityMeta } from "../engine/registry";
|
|
import {
|
|
PLATFORM_GROUPS,
|
|
buildDomainPlatformMap,
|
|
capabilityDomains
|
|
} from "./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();
|
|
expect(capabilityCount()).toBeGreaterThan(700);
|
|
expect(map.size).toBe(capabilityCount());
|
|
for (const id of map.keys()) {
|
|
const meta = getCapabilityMeta(id);
|
|
expect(meta, `能力 ${id} 无 meta`).toBeTruthy();
|
|
expect(meta!.platforms, `能力 ${id} 的 meta.platforms 未从分组表派生`).toEqual(["win32"]);
|
|
}
|
|
});
|
|
});
|