test: align runtime readiness checks with qualified Pi

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
DottaandPaperclip committed 2026-10-02 02:09:26 -05:00
1 parent 30edeec300
commit b70cf84ea6
2 files changed
+40 -12

No files matched your search

+18 -2
View File
@@ -4,13 +4,15 @@ import { listServerAdapters, requireServerAdapter } from "./registry.js";
import * as executionTarget from "@paperclipai/adapter-utils/execution-target";
import { BUILTIN_ADAPTER_TYPES } from "./builtin-adapter-types.js";
const { probeInstallation, probeGrokInstallation } = vi.hoisted(() => ({
const { probeInstallation, probeGrokInstallation, probePiInstallation } = vi.hoisted(() => ({
probeInstallation: vi.fn(),
probeGrokInstallation: vi.fn(),
probePiInstallation: vi.fn(),
}));
vi.mock("@paperclipai/paperclip-runner/live", () => ({
vi.mock("../vendor/paperclip-runner/index.js", () => ({
probeAcpxClaudeInstallation: probeInstallation,
probeAcpxGrokInstallation: probeGrokInstallation,
probeAcpxPiInstallation: probePiInstallation,
}));
// The registry registers a login capability for the two built-in interactive
@@ -95,6 +97,7 @@ describe("native ACPX environment checks", () => {
beforeEach(() => {
probeInstallation.mockReset().mockResolvedValue(undefined);
probeGrokInstallation.mockReset().mockResolvedValue(undefined);
probePiInstallation.mockReset().mockResolvedValue(undefined);
});
afterEach(() => vi.restoreAllMocks());
@@ -131,6 +134,19 @@ describe("native ACPX environment checks", () => {
expect(probeInstallation).not.toHaveBeenCalled();
});
it.each([true, false])("checks qualified Pi's own installation readiness (%s)", async (ready) => {
if (!ready) probePiInstallation.mockRejectedValueOnce(new Error("Pi installation integrity mismatch"));
const model = "openrouter/deepseek/deepseek-v4-flash-0731";
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({
...context,
config: { provider: "acpx", acpxAgent: "pi", model },
});
expect(result.status).toBe(ready ? "pass" : "fail");
expect(probePiInstallation).toHaveBeenCalledWith(model);
expect(probeInstallation).not.toHaveBeenCalled();
expect(probeGrokInstallation).not.toHaveBeenCalled();
});
it("does not use the host platform to reject a remote environment", async () => {
vi.spyOn(process, "platform", "get").mockReturnValue("darwin");
const result = await requireServerAdapter("paperclip_runner").testEnvironment!({
@@ -109,6 +109,20 @@ describe("resolveNativeRuntimeMode", () => {
});
});
it("admits qualified Pi without enabling pending ACPX candidates", () => {
expect(resolveNativeRuntimeMode({
...eligible,
adapterConfig: {
provider: "acpx",
acpxAgent: "pi",
model: "openrouter/deepseek/deepseek-v4-flash-0731",
},
})).toMatchObject({
kind: "native",
profile: { backend: "acpx_runtime" },
});
});
it("rejects malformed OpenCode and unqualified ACPX profiles", () => {
expect(() => resolveNativeRuntimeMode({
...eligible,
@@ -116,16 +130,14 @@ describe("resolveNativeRuntimeMode", () => {
})).toThrow(expect.objectContaining({
code: "paperclip_runner_opencode_model_invalid",
}));
expect(() => resolveNativeRuntimeMode({
...eligible,
adapterConfig: {
provider: "acpx",
acpxAgent: "pi",
model: "openrouter/deepseek/deepseek-v4-flash-0731",
},
})).toThrow(expect.objectContaining({
code: "paperclip_runner_acpx_agent_unavailable",
}));
for (const acpxAgent of ["cursor", "copilot"]) {
expect(() => resolveNativeRuntimeMode({
...eligible,
adapterConfig: { provider: "acpx", acpxAgent, model: "explicit-provider-model" },
})).toThrow(expect.objectContaining({
code: "paperclip_runner_acpx_agent_unavailable",
}));
}
expect(() => resolveNativeRuntimeMode({
...eligible,
adapterConfig: { provider: "acpx", acpxAgent: "claude", model: "claude-opus-5" },