test: centralize canonical skill fixtures

This commit is contained in:
Peter Steinberger
2026-03-28 03:41:55 +00:00
parent 63e35b2d9d
commit 24bb64b1c4
6 changed files with 33 additions and 40 deletions

View File

@@ -9,6 +9,7 @@ import {
hasBinaryMock,
runCommandWithTimeoutMock,
} from "./skills-install.test-mocks.js";
import { createCanonicalFixtureSkill } from "./skills.test-helpers.js";
import { resolveSkillToolsRootDir } from "./skills/tools-dir.js";
import type { SkillEntry, SkillInstallSpec } from "./skills/types.js";
@@ -74,14 +75,7 @@ function createFixtureSkill(params: {
baseDir: string;
source: string;
}): SkillEntry["skill"] {
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
source: params.source,
disableModelInvocation: false,
};
return createCanonicalFixtureSkill(params);
}
function buildDownloadSpec(params: {

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { buildWorkspaceSkillStatus } from "./skills-status.js";
import { createCanonicalFixtureSkill } from "./skills.test-helpers.js";
import type { SkillEntry } from "./skills/types.js";
describe("buildWorkspaceSkillStatus", () => {
@@ -48,12 +49,5 @@ function createFixtureSkill(params: {
baseDir: string;
source: string;
}): SkillEntry["skill"] {
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
source: params.source,
disableModelInvocation: false,
};
return createCanonicalFixtureSkill(params);
}

View File

@@ -5,6 +5,7 @@ import { afterEach, describe, expect, it } from "vitest";
import { withEnv, withEnvAsync } from "../test-utils/env.js";
import { buildWorkspaceSkillStatus } from "./skills-status.js";
import { writeSkill } from "./skills.e2e-test-helpers.js";
import { createCanonicalFixtureSkill } from "./skills.test-helpers.js";
import type { SkillEntry } from "./skills/types.js";
const tempDirs: string[] = [];
@@ -57,14 +58,7 @@ function createFixtureSkill(params: {
baseDir: string;
source: string;
}): SkillEntry["skill"] {
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
source: params.source,
disableModelInvocation: false,
};
return createCanonicalFixtureSkill(params);
}
describe("buildWorkspaceSkillStatus", () => {

View File

@@ -1,5 +1,6 @@
import { describe, expect, it } from "vitest";
import { resolveSkillsPromptForRun } from "./skills.js";
import { createCanonicalFixtureSkill } from "./skills.test-helpers.js";
import type { SkillEntry } from "./skills/types.js";
describe("resolveSkillsPromptForRun", () => {
@@ -37,12 +38,5 @@ function createFixtureSkill(params: {
baseDir: string;
source: string;
}): SkillEntry["skill"] {
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
source: params.source,
disableModelInvocation: false,
};
return createCanonicalFixtureSkill(params);
}

View File

@@ -1,5 +1,6 @@
import fs from "node:fs/promises";
import path from "node:path";
import { createSyntheticSourceInfo, type Skill } from "@mariozechner/pi-coding-agent";
export async function writeSkill(params: {
dir: string;
@@ -21,3 +22,25 @@ ${body ?? `# ${name}\n`}
"utf-8",
);
}
export function createCanonicalFixtureSkill(params: {
name: string;
description: string;
filePath: string;
baseDir: string;
source: string;
disableModelInvocation?: boolean;
}): Skill {
// Keep skill fixtures on the upstream canonical provenance shape.
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
sourceInfo: createSyntheticSourceInfo(params.filePath, {
source: params.source,
baseDir: params.baseDir,
}),
disableModelInvocation: params.disableModelInvocation ?? false,
};
}

View File

@@ -4,6 +4,7 @@ import path from "node:path";
import { afterAll, beforeAll, describe, expect, it } from "vitest";
import { buildWorkspaceSkillStatus } from "../agents/skills-status.js";
import type { SkillEntry } from "../agents/skills.js";
import { createCanonicalFixtureSkill } from "../agents/skills.test-helpers.js";
import { captureEnv } from "../test-utils/env.js";
import { formatSkillInfo, formatSkillsCheck, formatSkillsList } from "./skills-cli.format.js";
@@ -92,12 +93,5 @@ function createFixtureSkill(params: {
baseDir: string;
source: string;
}): SkillEntry["skill"] {
return {
name: params.name,
description: params.description,
filePath: params.filePath,
baseDir: params.baseDir,
source: params.source,
disableModelInvocation: false,
};
return createCanonicalFixtureSkill(params);
}