Skip to content

Commit 67bb8be

Browse files
committed
test(plugins): bind shared worker mocks before module evaluation
1 parent 172f17c commit 67bb8be

3 files changed

Lines changed: 17 additions & 3 deletions

File tree

‎src/plugins/plugin-lookup-table.test.ts‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,19 @@ import { resolveInstalledPluginIndexPolicyHash } from "./installed-plugin-index-
55
import type { PluginManifestRecord, PluginManifestRegistry } from "./manifest-registry.js";
66
import type { PluginRegistrySnapshot } from "./plugin-registry.js";
77

8-
const listPotentialConfiguredChannelIds = vi.hoisted(() => vi.fn());
9-
const listExplicitlyDisabledChannelIdsForConfig = vi.hoisted(() => vi.fn());
10-
const loadPluginManifestRegistryForInstalledIndex = vi.hoisted(() => vi.fn());
8+
const {
9+
listPotentialConfiguredChannelIds,
10+
listExplicitlyDisabledChannelIdsForConfig,
11+
loadPluginManifestRegistryForInstalledIndex,
12+
} = vi.hoisted(() => {
13+
// Shared plugin workers must load the lookup graph under this file's manifest mocks.
14+
vi.resetModules();
15+
return {
16+
listPotentialConfiguredChannelIds: vi.fn(),
17+
listExplicitlyDisabledChannelIdsForConfig: vi.fn(),
18+
loadPluginManifestRegistryForInstalledIndex: vi.fn(),
19+
};
20+
});
1121

1222
vi.mock("../channels/config-presence.js", () => ({
1323
hasMeaningfulChannelConfig: (value: unknown) =>

‎src/plugins/plugin-metadata-snapshot.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ const {
1818
loadPluginManifestRegistry,
1919
loadPluginManifestRegistryForInstalledIndex,
2020
} = vi.hoisted(() => {
21+
// Shared plugin workers must load this graph after this file's mocks are installed.
22+
vi.resetModules();
2123
return {
2224
loadPluginRegistrySnapshotWithMetadata: vi.fn(),
2325
loadPluginManifestRegistry: vi.fn(),

‎src/plugins/provider-discovery.runtime.test.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import type { PluginManifestRecord } from "./manifest-registry.js";
44
import type { ProviderPlugin } from "./types.js";
55

66
const mocks = vi.hoisted(() => {
7+
// Bind provider discovery to this file's mocks in non-isolated plugin workers.
8+
vi.resetModules();
79
const loadSource = vi.fn();
810
const loaderCache = { kind: "provider-discovery-loader-cache", clear: vi.fn() };
911
return {

0 commit comments

Comments
 (0)