mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-20 18:26:40 +01:00
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>
34 lines
1.8 KiB
TypeScript
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();
|
|
});
|