feat(FN-3096): update restart integration store mock for plugin templates
Updates the restart integration test mock to account for plugin template behavior, keeping the test in sync with recent plugin template changes. Fusion-Task-Id: FN-3096
This commit is contained in:
@@ -1895,6 +1895,7 @@ export default plugin;
|
||||
loader = new PluginLoader({ pluginStore, taskStore: mockTaskStore });
|
||||
expect(loader.getPluginSkills()).toEqual([]);
|
||||
expect(loader.getPluginWorkflowSteps()).toEqual([]);
|
||||
expect(loader.getPluginWorkflowStepTemplates()).toEqual([]);
|
||||
expect(loader.getPluginPromptContributions()).toEqual([]);
|
||||
expect(loader.getPluginSetupInfo()).toEqual([]);
|
||||
});
|
||||
@@ -1941,6 +1942,19 @@ export default plugin;
|
||||
step: { stepId: "wf", name: "WF", description: "desc", mode: "prompt", prompt: "check" },
|
||||
},
|
||||
]);
|
||||
expect(loader.getPluginWorkflowStepTemplates()).toEqual([
|
||||
{
|
||||
pluginId: "contrib-plugin",
|
||||
template: expect.objectContaining({
|
||||
id: "plugin:contrib-plugin:wf",
|
||||
name: "WF",
|
||||
description: "desc",
|
||||
prompt: "check",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
expect(loader.getPluginPromptContributions()).toEqual([
|
||||
{
|
||||
pluginId: "contrib-plugin",
|
||||
@@ -1960,6 +1974,48 @@ export default plugin;
|
||||
]);
|
||||
});
|
||||
|
||||
it("getPluginWorkflowStepTemplates maps multiple plugins with prefixed ids", async () => {
|
||||
await pluginStore.init();
|
||||
loader = new PluginLoader({ pluginStore, taskStore: mockTaskStore });
|
||||
(loader as any).plugins.set("alpha", {
|
||||
manifest: makeManifest({ id: "alpha" }),
|
||||
state: "started",
|
||||
hooks: {},
|
||||
workflowSteps: [{ stepId: "one", name: "One", description: "First", mode: "script", scriptName: "check" }],
|
||||
} as FusionPlugin);
|
||||
(loader as any).plugins.set("beta", {
|
||||
manifest: makeManifest({ id: "beta" }),
|
||||
state: "started",
|
||||
hooks: {},
|
||||
workflowSteps: [{ stepId: "two", name: "Two", description: "Second", mode: "prompt" }],
|
||||
} as FusionPlugin);
|
||||
|
||||
expect(loader.getPluginWorkflowStepTemplates()).toEqual([
|
||||
{
|
||||
pluginId: "alpha",
|
||||
template: expect.objectContaining({
|
||||
id: "plugin:alpha:one",
|
||||
name: "One",
|
||||
description: "First",
|
||||
prompt: "",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
}),
|
||||
},
|
||||
{
|
||||
pluginId: "beta",
|
||||
template: expect.objectContaining({
|
||||
id: "plugin:beta:two",
|
||||
name: "Two",
|
||||
description: "Second",
|
||||
prompt: "",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
}),
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
||||
it("stopped or unloaded plugins are not included", async () => {
|
||||
await pluginStore.init();
|
||||
loader = new PluginLoader({ pluginStore, taskStore: mockTaskStore });
|
||||
|
||||
@@ -8838,6 +8838,105 @@ Task with acceptance criteria
|
||||
expect(found).toBeUndefined();
|
||||
});
|
||||
|
||||
it("should resolve plugin workflow steps from injected templates", async () => {
|
||||
store.setPluginWorkflowStepTemplates([
|
||||
{
|
||||
pluginId: "my-plugin",
|
||||
template: {
|
||||
id: "plugin:my-plugin:my-step",
|
||||
name: "My Plugin Step",
|
||||
description: "Plugin-provided step",
|
||||
prompt: "Run plugin checks",
|
||||
toolMode: "readonly",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const step = await store.getWorkflowStep("plugin:my-plugin:my-step");
|
||||
expect(step).toMatchObject({
|
||||
id: "plugin:my-plugin:my-step",
|
||||
templateId: "my-step",
|
||||
name: "My Plugin Step",
|
||||
mode: "prompt",
|
||||
phase: "pre-merge",
|
||||
enabled: true,
|
||||
});
|
||||
});
|
||||
|
||||
it("should list db workflow steps and plugin workflow steps together", async () => {
|
||||
const dbStep = await store.createWorkflowStep({ name: "DB Step", description: "stored" });
|
||||
store.setPluginWorkflowStepTemplates([
|
||||
{
|
||||
pluginId: "my-plugin",
|
||||
template: {
|
||||
id: "plugin:my-plugin:my-step",
|
||||
name: "My Plugin Step",
|
||||
description: "Plugin-provided step",
|
||||
prompt: "Run plugin checks",
|
||||
toolMode: "coding",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const steps = await store.listWorkflowSteps();
|
||||
expect(steps.map((step) => step.id)).toEqual([dbStep.id, "plugin:my-plugin:my-step"]);
|
||||
});
|
||||
|
||||
it("should list disabled plugin steps without auto-materializing them", async () => {
|
||||
store.setPluginWorkflowStepTemplates([
|
||||
{
|
||||
pluginId: "my-plugin",
|
||||
template: {
|
||||
id: "plugin:my-plugin:disabled-step",
|
||||
name: "Disabled Plugin Step",
|
||||
description: "Plugin-provided step",
|
||||
prompt: "Run plugin checks",
|
||||
toolMode: "readonly",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
enabled: false,
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const listed = await store.listWorkflowSteps();
|
||||
expect(listed.find((step) => step.id === "plugin:my-plugin:disabled-step")?.enabled).toBe(false);
|
||||
|
||||
const task = await store.createTask({
|
||||
description: "Task with plugin-only workflow steps",
|
||||
enabledWorkflowSteps: ["plugin:my-plugin:disabled-step"],
|
||||
});
|
||||
expect(task.enabledWorkflowSteps).toEqual(["plugin:my-plugin:disabled-step"]);
|
||||
});
|
||||
|
||||
it("should keep plugin workflow IDs unchanged while materializing built-in templates", async () => {
|
||||
store.setPluginWorkflowStepTemplates([
|
||||
{
|
||||
pluginId: "my-plugin",
|
||||
template: {
|
||||
id: "plugin:my-plugin:my-step",
|
||||
name: "My Plugin Step",
|
||||
description: "Plugin-provided step",
|
||||
prompt: "Run plugin checks",
|
||||
toolMode: "readonly",
|
||||
category: "Plugin",
|
||||
icon: "puzzle",
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
const task = await store.createTask({
|
||||
description: "Task with mixed workflow steps",
|
||||
enabledWorkflowSteps: ["plugin:my-plugin:my-step", "browser-verification"],
|
||||
});
|
||||
|
||||
expect(task.enabledWorkflowSteps).toEqual(["plugin:my-plugin:my-step", "WS-001"]);
|
||||
});
|
||||
|
||||
it("should update a workflow step", async () => {
|
||||
const ws = await store.createWorkflowStep({
|
||||
name: "Original",
|
||||
|
||||
Reference in New Issue
Block a user