mirror of
https://github.com/farcasclaudiu/openclaw.git
synced 2026-06-29 03:01:50 +03:00
refactor(test): dedupe loadWorkspaceSkillEntries plugin setup
This commit is contained in:
@@ -26,6 +26,36 @@ ${body ?? `# ${name}\n`}
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function setupWorkspaceWithProsePlugin() {
|
||||||
|
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
||||||
|
const managedDir = path.join(workspaceDir, ".managed");
|
||||||
|
const bundledDir = path.join(workspaceDir, ".bundled");
|
||||||
|
const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose");
|
||||||
|
|
||||||
|
await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true });
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(pluginRoot, "openclaw.plugin.json"),
|
||||||
|
JSON.stringify(
|
||||||
|
{
|
||||||
|
id: "open-prose",
|
||||||
|
skills: ["./skills"],
|
||||||
|
configSchema: { type: "object", additionalProperties: false, properties: {} },
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
2,
|
||||||
|
),
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8");
|
||||||
|
await fs.writeFile(
|
||||||
|
path.join(pluginRoot, "skills", "prose", "SKILL.md"),
|
||||||
|
`---\nname: prose\ndescription: test\n---\n`,
|
||||||
|
"utf-8",
|
||||||
|
);
|
||||||
|
|
||||||
|
return { workspaceDir, managedDir, bundledDir };
|
||||||
|
}
|
||||||
|
|
||||||
describe("loadWorkspaceSkillEntries", () => {
|
describe("loadWorkspaceSkillEntries", () => {
|
||||||
it("handles an empty managed skills dir without throwing", async () => {
|
it("handles an empty managed skills dir without throwing", async () => {
|
||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
||||||
@@ -41,31 +71,7 @@ describe("loadWorkspaceSkillEntries", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("includes plugin-shipped skills when the plugin is enabled", async () => {
|
it("includes plugin-shipped skills when the plugin is enabled", async () => {
|
||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithProsePlugin();
|
||||||
const managedDir = path.join(workspaceDir, ".managed");
|
|
||||||
const bundledDir = path.join(workspaceDir, ".bundled");
|
|
||||||
const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose");
|
|
||||||
|
|
||||||
await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true });
|
|
||||||
await fs.writeFile(
|
|
||||||
path.join(pluginRoot, "openclaw.plugin.json"),
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
id: "open-prose",
|
|
||||||
skills: ["./skills"],
|
|
||||||
configSchema: { type: "object", additionalProperties: false, properties: {} },
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
"utf-8",
|
|
||||||
);
|
|
||||||
await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8");
|
|
||||||
await fs.writeFile(
|
|
||||||
path.join(pluginRoot, "skills", "prose", "SKILL.md"),
|
|
||||||
`---\nname: prose\ndescription: test\n---\n`,
|
|
||||||
"utf-8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
||||||
config: {
|
config: {
|
||||||
@@ -81,31 +87,7 @@ describe("loadWorkspaceSkillEntries", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("excludes plugin-shipped skills when the plugin is not allowed", async () => {
|
it("excludes plugin-shipped skills when the plugin is not allowed", async () => {
|
||||||
const workspaceDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-"));
|
const { workspaceDir, managedDir, bundledDir } = await setupWorkspaceWithProsePlugin();
|
||||||
const managedDir = path.join(workspaceDir, ".managed");
|
|
||||||
const bundledDir = path.join(workspaceDir, ".bundled");
|
|
||||||
const pluginRoot = path.join(workspaceDir, ".openclaw", "extensions", "open-prose");
|
|
||||||
|
|
||||||
await fs.mkdir(path.join(pluginRoot, "skills", "prose"), { recursive: true });
|
|
||||||
await fs.writeFile(
|
|
||||||
path.join(pluginRoot, "openclaw.plugin.json"),
|
|
||||||
JSON.stringify(
|
|
||||||
{
|
|
||||||
id: "open-prose",
|
|
||||||
skills: ["./skills"],
|
|
||||||
configSchema: { type: "object", additionalProperties: false, properties: {} },
|
|
||||||
},
|
|
||||||
null,
|
|
||||||
2,
|
|
||||||
),
|
|
||||||
"utf-8",
|
|
||||||
);
|
|
||||||
await fs.writeFile(path.join(pluginRoot, "index.ts"), "export {};\n", "utf-8");
|
|
||||||
await fs.writeFile(
|
|
||||||
path.join(pluginRoot, "skills", "prose", "SKILL.md"),
|
|
||||||
`---\nname: prose\ndescription: test\n---\n`,
|
|
||||||
"utf-8",
|
|
||||||
);
|
|
||||||
|
|
||||||
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
const entries = loadWorkspaceSkillEntries(workspaceDir, {
|
||||||
config: {
|
config: {
|
||||||
|
|||||||
Reference in New Issue
Block a user