48 lines
2.3 KiB
TypeScript
48 lines
2.3 KiB
TypeScript
/**
|
|
* CAD 명령 목록 거울(PLAN 332-2) — `commands/command-catalog.json` 이 registry(`commands.*.ts`)와 같은지.
|
|
* ☰ [설정] CAD 단축키 탭은 xstate 가 딸려 오지 않게 JSON 만 읽음 — 명령을 더하거나 별칭을 바꾸면 JSON 도 같이.
|
|
* 실행: cd B07_DesignDetail/openwebcad && npx vitest run --dir ../../resources/tester/cad command-catalog
|
|
*/
|
|
import { describe, expect, it } from "vitest";
|
|
|
|
import catalog from "../../../B07_DesignDetail/openwebcad/src/commands/command-catalog.json";
|
|
import { getAllCommands } from "../../../B07_DesignDetail/openwebcad/src/commands/registry";
|
|
import { RIBBON_TABS } from "../../../B07_DesignDetail/openwebcad/src/ribbon/ribbon.config";
|
|
|
|
describe("command-catalog.json", () => {
|
|
it("registry 와 같은 명령 · 한글 이름 · 기본 별칭 · 차례", () => {
|
|
const live = getAllCommands().map((c) => ({
|
|
id: c.id,
|
|
label: c.label,
|
|
aliases: c.aliases ?? [],
|
|
}));
|
|
expect(catalog).toEqual(live);
|
|
});
|
|
|
|
it("기본 별칭 = 영문 · 숫자 · 안 겹침 · 명령 이름과 다름", () => {
|
|
const ids = new Set(catalog.map((c) => c.id));
|
|
const aliases = catalog.flatMap((c) => c.aliases);
|
|
expect(aliases.every((a) => /^[A-Z0-9]+$/.test(a))).toBe(true);
|
|
expect(new Set(aliases).size).toBe(aliases.length);
|
|
expect(aliases.filter((a) => ids.has(a))).toEqual([]);
|
|
});
|
|
|
|
it("337 acad.pgp 맞춤 — SE 없음(acad = DSETTINGS) · ED = TEXTEDIT", () => {
|
|
const owner = (alias: string) => catalog.find((c) => c.aliases.includes(alias))?.id;
|
|
expect(owner("SE")).toBeUndefined();
|
|
expect(owner("ED")).toBe("TEXTEDIT");
|
|
});
|
|
|
|
it("488 — 이름 · 설명에 「도면층」 · 「선가중치」 없음(레이어 · 선 두께)", () => {
|
|
const words = getAllCommands().flatMap((c) => [c.label, c.hint ?? ""]);
|
|
expect(words.filter((w) => /도면층|선가중치/.test(w))).toEqual([]);
|
|
expect(catalog.find((c) => c.id === "LAYER")?.label).toContain("레이어");
|
|
});
|
|
|
|
it("488 — 삽입 탭에 [DWG 불러오기](IMPORT)", () => {
|
|
const insert = RIBBON_TABS.find((tab) => tab.id === "insert");
|
|
expect(insert?.panels.flatMap((panel) => panel.big ?? [])).toContain("IMPORT");
|
|
expect(catalog.find((c) => c.id === "IMPORT")?.label).toBe("DWG 불러오기");
|
|
});
|
|
});
|