83 lines
2.9 KiB
TypeScript
83 lines
2.9 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
|
|
import { LOCAL_AUDIT_SKILL_REGISTRY_SOURCE } from "../lib/ai/local-audit-skill-registry";
|
|
import { parseSkillsRegistry, toAuditUsedSkill } from "../lib/skills-registry";
|
|
|
|
test("parseSkillsRegistry parses v3 yaml metablocks from the MVP registry source", () => {
|
|
const parsed = parseSkillsRegistry(LOCAL_AUDIT_SKILL_REGISTRY_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", () => {
|
|
const parsed = parseSkillsRegistry(LOCAL_AUDIT_SKILL_REGISTRY_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", () => {
|
|
const parsed = parseSkillsRegistry(LOCAL_AUDIT_SKILL_REGISTRY_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"]);
|
|
});
|