Skip to content

Commit cd2e13b

Browse files
committed
test: isolate channel catalog fixtures
1 parent 84154bb commit cd2e13b

1 file changed

Lines changed: 24 additions & 19 deletions

File tree

‎src/channels/plugins/contracts/test-helpers/channel-catalog-contract.ts‎

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@ type CatalogEntryMeta = {
1414
aliases?: string[];
1515
};
1616

17+
function createCatalogFixtureEnv(overrides: NodeJS.ProcessEnv = {}): NodeJS.ProcessEnv {
18+
return {
19+
...process.env,
20+
OPENCLAW_DISABLE_PLUGIN_DISCOVERY_CACHE: "1",
21+
OPENCLAW_DISABLE_PLUGIN_MANIFEST_CACHE: "1",
22+
...overrides,
23+
};
24+
}
25+
26+
function createCatalogFallbackOnlyEnv(): NodeJS.ProcessEnv {
27+
return createCatalogFixtureEnv({
28+
OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1",
29+
OPENCLAW_BUNDLED_PLUGINS_DIR: "/nonexistent/bundled/plugins",
30+
});
31+
}
32+
1733
export function describeChannelCatalogEntryContract(params: {
1834
channelId: string;
1935
npmSpec: string;
@@ -44,13 +60,13 @@ export function describeBundledMetadataOnlyChannelCatalogContract(params: {
4460
}) {
4561
describe(`${params.pluginId} bundled metadata-only channel catalog contract`, () => {
4662
it("includes the bundled metadata-only channel entry when the runtime entrypoint is omitted", () => {
47-
const packageRoot = fs.mkdtempSync(
63+
const workspaceDir = fs.mkdtempSync(
4864
path.join(resolvePreferredOpenClawTmpDir(), "openclaw-bundled-catalog-"),
4965
);
50-
const bundledDir = path.join(packageRoot, "dist", "extensions", params.pluginId);
66+
const bundledDir = path.join(workspaceDir, ".openclaw", "extensions", params.pluginId);
5167
fs.mkdirSync(bundledDir, { recursive: true });
5268
fs.writeFileSync(
53-
path.join(packageRoot, "package.json"),
69+
path.join(workspaceDir, "package.json"),
5470
JSON.stringify({ name: "openclaw" }),
5571
"utf8",
5672
);
@@ -77,10 +93,8 @@ export function describeBundledMetadataOnlyChannelCatalogContract(params: {
7793
);
7894

7995
const entry = listChannelPluginCatalogEntries({
80-
env: {
81-
...process.env,
82-
OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(packageRoot, "dist", "extensions"),
83-
},
96+
workspaceDir,
97+
env: createCatalogFixtureEnv({ OPENCLAW_DISABLE_BUNDLED_PLUGINS: "1" }),
8498
}).find((item) => item.id === params.meta.id);
8599

86100
expect(entry?.install.npmSpec).toBe(params.npmSpec);
@@ -123,10 +137,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
123137
);
124138

125139
const entry = listChannelPluginCatalogEntries({
126-
env: {
127-
...process.env,
128-
OPENCLAW_BUNDLED_PLUGINS_DIR: "/nonexistent/bundled/plugins",
129-
},
140+
env: createCatalogFallbackOnlyEnv(),
130141
officialCatalogPaths: [catalogPath],
131142
}).find((item) => item.id === params.channelId);
132143

@@ -202,10 +213,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
202213
const entry = listChannelPluginCatalogEntries({
203214
catalogPaths: [externalCatalogPath],
204215
officialCatalogPaths: [officialCatalogPath],
205-
env: {
206-
...process.env,
207-
OPENCLAW_BUNDLED_PLUGINS_DIR: path.join(dir, "dist", "extensions"),
208-
},
216+
env: createCatalogFallbackOnlyEnv(),
209217
}).find((item) => item.id === params.channelId);
210218

211219
expect(entry?.install.npmSpec).toBe(params.externalNpmSpec);
@@ -240,10 +248,7 @@ export function describeOfficialFallbackChannelCatalogContract(params: {
240248
const entry = listChannelPluginCatalogEntries({
241249
catalogPaths: [catalogPath],
242250
officialCatalogPaths: [],
243-
env: {
244-
...process.env,
245-
OPENCLAW_BUNDLED_PLUGINS_DIR: "/nonexistent/bundled/plugins",
246-
},
251+
env: createCatalogFallbackOnlyEnv(),
247252
}).find((item) => item.id === params.channelId);
248253

249254
expect(entry?.installSource?.npm).toMatchObject({

0 commit comments

Comments
 (0)