Files
openclaw/test/scripts/channel-contract-test-plan.test.ts
Peter Steinberger c70aee247e refactor(scripts): migrate JavaScript tools to TypeScript (#121005)
* refactor(scripts): migrate JavaScript tools to TypeScript

* fix(ci): keep changed-scope preflight zero-install

* fix(ci): preserve zero-install script owners

* fix(ci): complete script migration follow-through

* fix(release): keep stable closeout zero-install

* fix(scripts): preserve standalone execution boundaries

* fix(scripts): repair standalone loader boundaries

* fix(scripts): normalize gateway observation ids

* fix(scripts): keep Docker packager standalone

* test(scripts): preserve rebase cleanup helpers

* test(sessions): use tracked temp directory
2026-08-09 07:21:35 -07:00

66 lines
2.4 KiB
TypeScript

// Channel Contract Test Plan tests cover channel contract test plan script behavior.
import { describe, expect, it } from "vitest";
import { createChannelContractTestShards } from "../../scripts/lib/channel-contract-test-plan.mts";
import { expectNoNodeFsScans } from "../../src/test-utils/fs-scan-assertions.js";
import { listGitTrackedFiles } from "../../src/test-utils/repo-files.js";
function listContractTests(rootDir = "src/channels/plugins/contracts"): string[] {
const files = listGitTrackedFiles({ pathspecs: rootDir });
expect(files).not.toBeNull();
return (files ?? []).filter((line) => line.endsWith(".test.ts"));
}
describe("scripts/lib/channel-contract-test-plan.mts", () => {
it("splits channel contracts into focused shards", () => {
const suffixes = ["a", "b"];
expect(
createChannelContractTestShards().map((shard) => ({
checkName: shard.checkName,
runtime: shard.runtime,
task: shard.task,
})),
).toEqual(
suffixes.map((suffix) => ({
checkName: `checks-fast-contracts-channels-${suffix}`,
runtime: "node",
task: "contracts-channels",
})),
);
});
it("covers every channel contract test exactly once", () => {
const actual = createChannelContractTestShards()
.flatMap((shard) => shard.includePatterns)
.toSorted((a, b) => a.localeCompare(b));
expect(actual).toEqual(listContractTests());
expect(new Set(actual).size).toBe(actual.length);
});
it("uses git-tracked files without walking contract directories", () => {
const payload = expectNoNodeFsScans<{
files: number;
shards: number;
}>(`
const { createChannelContractTestShards } = await import("./scripts/lib/channel-contract-test-plan.mts");
const shards = createChannelContractTestShards();
return {
files: shards.reduce((total, shard) => total + shard.includePatterns.length, 0),
shards: shards.length,
};
`);
expect(payload.shards).toBe(2);
expect(payload.files).toBeGreaterThan(0);
});
it("keeps registry-backed surface shards spread across checks", () => {
for (const shard of createChannelContractTestShards()) {
const surfaceRegistryFiles = shard.includePatterns.filter((pattern) =>
pattern.includes("/surfaces-only.registry-backed-shard-"),
);
expect(surfaceRegistryFiles.length).toBeLessThanOrEqual(6);
}
});
});