|
| 1 | +// Thread-binding artifact parity contract for bundled channel plugins. |
| 2 | +// |
| 3 | +// Core resolves default thread placement from lightweight `thread-binding-api` |
| 4 | +// artifacts before full plugin loading (src/channels/plugins/thread-binding-api.ts). |
| 5 | +// This suite pins artifact exports to the runtime plugin's conversationBindings |
| 6 | +// so the fast path cannot drift from loaded-plugin behavior. |
| 7 | +import { beforeAll, describe, expect, it } from "vitest"; |
| 8 | +import { |
| 9 | + getBundledChannelPluginAsync, |
| 10 | + getBundledChannelThreadBindingArtifactAsync, |
| 11 | + listBundledChannelPluginIds, |
| 12 | +} from "./test-helpers/bundled-channel-plugin-loader.js"; |
| 13 | + |
| 14 | +// Bundled channels expected to ship a top-level thread-binding artifact. |
| 15 | +const THREAD_BINDING_ARTIFACT_PLUGIN_IDS = ["discord", "matrix"] as const; |
| 16 | + |
| 17 | +describe("bundled channel thread-binding artifact parity", () => { |
| 18 | + const artifactPlacements = new Map<string, unknown>(); |
| 19 | + |
| 20 | + beforeAll(async () => { |
| 21 | + for (const id of listBundledChannelPluginIds()) { |
| 22 | + const artifact = await getBundledChannelThreadBindingArtifactAsync(id); |
| 23 | + if (artifact) { |
| 24 | + artifactPlacements.set(id, artifact.defaultTopLevelPlacement); |
| 25 | + } |
| 26 | + } |
| 27 | + }); |
| 28 | + |
| 29 | + it("keeps the artifact table in sync with bundled channels that ship one", () => { |
| 30 | + expect([...artifactPlacements.keys()].toSorted()).toEqual([ |
| 31 | + ...THREAD_BINDING_ARTIFACT_PLUGIN_IDS, |
| 32 | + ]); |
| 33 | + }); |
| 34 | + |
| 35 | + it.each(THREAD_BINDING_ARTIFACT_PLUGIN_IDS)( |
| 36 | + "keeps the %s artifact placement equal to the runtime plugin default", |
| 37 | + async (id) => { |
| 38 | + const artifactPlacement = artifactPlacements.get(id); |
| 39 | + expect(["current", "child"]).toContain(artifactPlacement); |
| 40 | + |
| 41 | + const plugin = await getBundledChannelPluginAsync(id); |
| 42 | + expect(plugin?.conversationBindings?.defaultTopLevelPlacement).toBe(artifactPlacement); |
| 43 | + }, |
| 44 | + ); |
| 45 | +}); |
0 commit comments