test: fix prep gate regressions

This commit is contained in:
Gustavo Madeira Santana
2026-04-14 14:53:37 -04:00
parent ddabdf67c1
commit aea6b5954f
2 changed files with 32 additions and 18 deletions

View File

@@ -1,4 +1,5 @@
import { Command } from "commander";
import type { QaRunnerCliContribution } from "openclaw/plugin-sdk/qa-runner-runtime";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
const TEST_QA_RUNNER = {
@@ -19,6 +20,25 @@ function createAvailableQaRunnerContribution() {
qa.command(TEST_QA_RUNNER.commandName).action(() => undefined);
}),
},
} satisfies QaRunnerCliContribution;
}
function createMissingQaRunnerContribution(): QaRunnerCliContribution {
return {
pluginId: TEST_QA_RUNNER.pluginId,
commandName: TEST_QA_RUNNER.commandName,
description: TEST_QA_RUNNER.description,
status: "missing",
npmSpec: TEST_QA_RUNNER.npmSpec,
};
}
function createBlockedQaRunnerContribution(): QaRunnerCliContribution {
return {
pluginId: TEST_QA_RUNNER.pluginId,
commandName: TEST_QA_RUNNER.commandName,
description: TEST_QA_RUNNER.description,
status: "blocked",
};
}
@@ -97,15 +117,7 @@ describe("qa cli registration", () => {
});
it("shows an install hint when a discovered runner plugin is unavailable", async () => {
listQaRunnerCliContributions.mockReset().mockReturnValue([
{
pluginId: TEST_QA_RUNNER.pluginId,
commandName: TEST_QA_RUNNER.commandName,
description: TEST_QA_RUNNER.description,
status: "missing",
npmSpec: TEST_QA_RUNNER.npmSpec,
},
]);
listQaRunnerCliContributions.mockReset().mockReturnValue([createMissingQaRunnerContribution()]);
const missingProgram = new Command();
registerQaLabCli(missingProgram);
@@ -115,14 +127,7 @@ describe("qa cli registration", () => {
});
it("shows an enable hint when a discovered runner plugin is installed but blocked", async () => {
listQaRunnerCliContributions.mockReset().mockReturnValue([
{
pluginId: TEST_QA_RUNNER.pluginId,
commandName: TEST_QA_RUNNER.commandName,
description: TEST_QA_RUNNER.description,
status: "blocked",
},
]);
listQaRunnerCliContributions.mockReset().mockReturnValue([createBlockedQaRunnerContribution()]);
const blockedProgram = new Command();
registerQaLabCli(blockedProgram);

View File

@@ -3,7 +3,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
const loadPluginManifestRegistry = vi.hoisted(() => vi.fn());
const tryLoadActivatedBundledPluginPublicSurfaceModuleSync = vi.hoisted(() => vi.fn());
const listBundledQaRunnerCatalog = vi.hoisted(() => vi.fn(() => []));
const listBundledQaRunnerCatalog = vi.hoisted(() =>
vi.fn<
() => Array<{
pluginId: string;
commandName: string;
description?: string;
npmSpec: string;
}>
>(() => []),
);
vi.mock("../plugins/manifest-registry.js", () => ({
loadPluginManifestRegistry,