Skip to content

Commit 48cf443

Browse files
committed
test(plugins): guard dedicated channel sidecars
1 parent 03d5ad5 commit 48cf443

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

test/scripts/bundled-plugin-build-entries.test.ts

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,61 @@ describe("bundled plugin build entries", () => {
220220
}
221221
});
222222

223+
it("keeps dedicated channel contract exports off broad contract-api sidecars", () => {
224+
const duplicateExportMarkersByArtifact = {
225+
"directory-contract-api.ts": [
226+
"DirectoryContractPlugin",
227+
"DirectoryGroupsFromConfig",
228+
"DirectoryPeersFromConfig",
229+
],
230+
"doctor-contract-api.ts": [
231+
"legacyConfigRules",
232+
"normalizeCompatibilityConfig",
233+
"stateMigrations",
234+
],
235+
"secret-contract-api.ts": [
236+
"channelSecrets",
237+
"collectRuntimeConfigAssignments",
238+
"secretTargetRegistryEntries",
239+
],
240+
"security-audit-contract-api.ts": ["SecurityAuditFindings"],
241+
"security-contract-api.ts": [
242+
"collectUnsupportedSecretRefConfigCandidates",
243+
"unsupportedSecretRefSurfacePatterns",
244+
],
245+
"session-binding-contract-api.ts": [
246+
"ConversationBindingManager",
247+
"ThreadBindingManager",
248+
"ThreadBindingsForTests",
249+
"setMatrixRuntime",
250+
],
251+
} as const;
252+
const offenders: string[] = [];
253+
254+
for (const dirent of fs.readdirSync("extensions", { withFileTypes: true })) {
255+
if (!dirent.isDirectory()) {
256+
continue;
257+
}
258+
const contractApiPath = path.join("extensions", dirent.name, "contract-api.ts");
259+
if (!fs.existsSync(contractApiPath)) {
260+
continue;
261+
}
262+
const contractApi = fs.readFileSync(contractApiPath, "utf8");
263+
for (const [artifact, markers] of Object.entries(duplicateExportMarkersByArtifact)) {
264+
if (!fs.existsSync(path.join("extensions", dirent.name, artifact))) {
265+
continue;
266+
}
267+
for (const marker of markers) {
268+
if (contractApi.includes(marker)) {
269+
offenders.push(`${contractApiPath} duplicates ${artifact}: ${marker}`);
270+
}
271+
}
272+
}
273+
}
274+
275+
expect(offenders).toStrictEqual([]);
276+
});
277+
223278
it("keeps bundled channel entry metadata on packed top-level sidecars", () => {
224279
const offenders: string[] = [];
225280

0 commit comments

Comments
 (0)