Files
PaperClipAI/server/src/__tests__/cloud-configuration-qualification.test.ts
T
Devin FoleyandPaperclip 417802ca87 fix(plugins): refresh unchanged-version bundle descriptions (#22295)
Refresh known display descriptions in same-version bundled plugin registrations only when every behavioral field matches. Compare manifests in their persisted JSON form and await bundle reconciliation before final volume-free package qualification.

Verified 77 focused tests, server typechecking, and all 59 successful PR checks. Greptile 5/5 with no unresolved review comments.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-11-19 09:26:06 -08:00

34 lines
1.8 KiB
TypeScript

import { beforeEach, expect, it, vi } from "vitest";
import { qualifyCloudConfigurationForCurrentImage } from "../services/cloud-configuration-qualification.js";
const { qualify } = vi.hoisted(() => ({ qualify: vi.fn() }));
vi.mock("../services/cloud-configuration-migration.js", () => ({ cloudConfigurationMigrationService: () => ({ qualify }) }));
vi.mock("../services/plugin-loader.js", () => ({ pluginLoader: () => ({ loadManifest: async () => null }) }));
beforeEach(() => { qualify.mockReset(); });
it("waits for a delayed bundled manifest update before qualifying a volume-free image", async () => {
let release!: () => void;
let manifestUpdated = false;
const manifestsReady = new Promise<void>(resolve => { release = () => { manifestUpdated = true; resolve(); }; });
qualify.mockImplementation(async () => {
expect(manifestUpdated).toBe(true);
return { configurationPackagesEligible: true };
});
const result = qualifyCloudConfigurationForCurrentImage({} as Parameters<typeof qualifyCloudConfigurationForCurrentImage>[0], {
runtimeEnv: { PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN: "tenant-fixture" }, bundledManifestsReady: manifestsReady,
});
await Promise.resolve();
expect(qualify).not.toHaveBeenCalled();
release();
await expect(result).resolves.toMatchObject({ configurationPackagesEligible: true });
expect(qualify).toHaveBeenCalledTimes(1);
});
it("does not qualify when bundled manifest reconciliation rejects", async () => {
await expect(qualifyCloudConfigurationForCurrentImage({} as Parameters<typeof qualifyCloudConfigurationForCurrentImage>[0], {
runtimeEnv: { PAPERCLIP_CLOUD_TENANT_SERVER_TOKEN: "tenant-fixture" }, bundledManifestsReady: Promise.reject(new Error("refresh failed")),
})).rejects.toThrow("refresh failed");
expect(qualify).not.toHaveBeenCalled();
});