Externalize audit pipeline services
This commit is contained in:
87
tests/audit-skill-registry-v3.test.ts
Normal file
87
tests/audit-skill-registry-v3.test.ts
Normal file
@@ -0,0 +1,87 @@
|
||||
import assert from "node:assert/strict";
|
||||
import { readFile } from "node:fs/promises";
|
||||
import { join } from "node:path";
|
||||
import test from "node:test";
|
||||
|
||||
import { parseSkillsRegistry, toAuditUsedSkill } from "../lib/skills-registry";
|
||||
|
||||
test("parseSkillsRegistry parses v3 yaml metablocks from v2 source", async () => {
|
||||
const source = await readFile(join(process.cwd(), "v2_elemente", "skills.md"), "utf8");
|
||||
|
||||
const parsed = parseSkillsRegistry(source);
|
||||
|
||||
assert.equal(parsed.length, 9);
|
||||
const visualDesign = parsed.find((entry) => entry.id === "visual-design");
|
||||
assert.ok(visualDesign);
|
||||
assert.equal(visualDesign.title, "Visueller Gesamteindruck & Zeitgemäßheit");
|
||||
assert.equal(visualDesign.name, "Visueller Gesamteindruck & Zeitgemäßheit");
|
||||
assert.equal(visualDesign.appliesWhen, "website_exists");
|
||||
assert.deepEqual(visualDesign.inputs, [
|
||||
"desktop_screenshot",
|
||||
"mobile_screenshot",
|
||||
]);
|
||||
assert.equal(visualDesign.outputs, "findings");
|
||||
const instructions = visualDesign.instructions;
|
||||
if (typeof instructions !== "string") {
|
||||
assert.fail("Expected visual-design instructions to be parsed.");
|
||||
}
|
||||
assert.match(instructions, /Beurteile den ersten visuellen Eindruck/);
|
||||
});
|
||||
|
||||
test("toAuditUsedSkill exposes stable ids for v3 registry entries", async () => {
|
||||
const source = await readFile(join(process.cwd(), "v2_elemente", "skills.md"), "utf8");
|
||||
const parsed = parseSkillsRegistry(source);
|
||||
const skill = parsed.find((entry) => entry.id === "contact-conversion");
|
||||
|
||||
assert.ok(skill);
|
||||
assert.deepEqual(toAuditUsedSkill(skill), {
|
||||
id: "contact-conversion",
|
||||
name: "Kontaktaufnahme & Handlungsaufforderung",
|
||||
});
|
||||
});
|
||||
|
||||
test("parseSkillsRegistry does not infer categories for v3 entries without explicit metadata", async () => {
|
||||
const source = await readFile(join(process.cwd(), "v2_elemente", "skills.md"), "utf8");
|
||||
const parsed = parseSkillsRegistry(source);
|
||||
const skill = parsed.find((entry) => entry.id === "performance-experience");
|
||||
|
||||
assert.ok(skill);
|
||||
assert.equal(skill.category, undefined);
|
||||
assert.deepEqual(toAuditUsedSkill(skill), {
|
||||
id: "performance-experience",
|
||||
name: "Tempo & Ladeerlebnis",
|
||||
});
|
||||
});
|
||||
|
||||
test("parseSkillsRegistry can read legacy and v3 skill sections from one registry", () => {
|
||||
const source = `
|
||||
## Legacy Copy Skill
|
||||
Purpose: Improve customer-facing copy.
|
||||
When to use: Use when page text is unclear.
|
||||
When not to use: Skip when copy is not available.
|
||||
Required input: Markdown copy.
|
||||
Expected output: Copy recommendations.
|
||||
Category: copy
|
||||
|
||||
## mobile-usability
|
||||
|
||||
\`\`\`yaml
|
||||
id: mobile-usability
|
||||
title: Mobile Nutzbarkeit
|
||||
applies_when: has_mobile_screenshot
|
||||
inputs: [mobile_screenshot, pagespeed]
|
||||
outputs: findings
|
||||
\`\`\`
|
||||
|
||||
Pruefe mobile Lesbarkeit und Tap-Ziele.
|
||||
`;
|
||||
|
||||
const parsed = parseSkillsRegistry(source);
|
||||
|
||||
assert.equal(parsed.length, 2);
|
||||
assert.equal(parsed[0].name, "Legacy Copy Skill");
|
||||
assert.equal(parsed[0].category, "copy");
|
||||
assert.equal(parsed[1].id, "mobile-usability");
|
||||
assert.equal(parsed[1].category, undefined);
|
||||
assert.deepEqual(parsed[1].inputs, ["mobile_screenshot", "pagespeed"]);
|
||||
});
|
||||
Reference in New Issue
Block a user