test: align runtime fixture expectations

This commit is contained in:
Peter Steinberger
2026-05-02 10:41:42 +01:00
parent 47de32ac21
commit 701811e013
10 changed files with 65 additions and 30 deletions

View File

@@ -63,7 +63,7 @@ vi.mock("../plugins/manifest-registry.js", () => ({
}));
vi.mock("../plugins/manifest-registry-installed.js", () => ({
loadPluginManifestRegistryForInstalledIndex: loadPluginManifestRegistry,
resolveInstalledManifestRegistryIndexFingerprint: () => "test-index",
resolveInstalledManifestRegistryIndexFingerprint: () => "test-installed-index",
}));
vi.mock("../plugins/plugin-registry.js", () => ({
loadPluginRegistrySnapshot: () => ({ plugins: [] }),

View File

@@ -1328,13 +1328,6 @@ describe("compactEmbeddedPiSession hooks (ownsCompaction engine)", () => {
sessionFile: TEST_SESSION_FILE,
},
} as never);
rotateTranscriptAfterCompactionMock.mockResolvedValueOnce({
rotated: true,
sessionId: "wrapper-rotated-session",
sessionFile: "/tmp/wrapper-rotated-session.jsonl",
leafId: "wrapper-rotated-leaf",
});
const result = await compactEmbeddedPiSession(
wrappedCompactionArgs({
config: {

View File

@@ -65,12 +65,12 @@ async function spawn(params?: {
runTimeoutSeconds?: number;
thread?: boolean;
mode?: "run" | "session";
context?: "isolated" | "fork";
agentSessionKey?: string;
agentChannel?: string;
agentAccountId?: string;
agentTo?: string;
agentThreadId?: string | number;
context?: "isolated";
}) {
return await spawnSubagentDirect(
{
@@ -81,7 +81,7 @@ async function spawn(params?: {
: {}),
...(params?.thread ? { thread: true } : {}),
...(params?.mode ? { mode: params.mode } : {}),
...(params?.context ? { context: params.context } : {}),
context: params?.context ?? "isolated",
},
{
agentSessionKey: params?.agentSessionKey ?? "main",
@@ -170,6 +170,9 @@ describe("sessions_spawn subagent lifecycle hooks", () => {
session: {
mainKey: "main",
scope: "per-sender",
threadBindings: {
defaultSpawnContext: "isolated",
},
},
});
const store: Record<string, Record<string, unknown>> = {};

View File

@@ -55,6 +55,11 @@ describe("spawnSubagentDirect thread binding delivery", () => {
},
list: [{ id: "main", workspace: "/tmp/workspace-main" }],
},
session: {
threadBindings: {
defaultSpawnContext: "isolated",
},
},
});
currentSessionBindingService = { listBySession: () => [] };
currentDeliveryTargetResolver = (params) => ({

View File

@@ -53,6 +53,11 @@ function createConfigOverride(overrides?: Record<string, unknown>) {
},
],
},
session: {
threadBindings: {
defaultSpawnContext: "isolated",
},
},
...overrides,
});
}

View File

@@ -18,6 +18,7 @@ const listChannelPluginCatalogEntries = vi.hoisted(() => vi.fn((_opts?: unknown)
const listChatChannels = vi.hoisted(() => vi.fn((): unknown[] => []));
const loadPluginManifestRegistry = vi.hoisted(() => vi.fn());
const loadPluginRegistrySnapshot = vi.hoisted(() => vi.fn());
const loadPluginRegistrySnapshotWithMetadata = vi.hoisted(() => vi.fn());
const listPluginContributionIds = vi.hoisted(() => vi.fn((_params?: unknown): string[] => []));
const applyPluginAutoEnable = vi.hoisted(() =>
vi.fn(({ config }: { config: unknown }) => ({
@@ -44,11 +45,8 @@ vi.mock("../../plugins/plugin-registry.js", () => ({
loadPluginManifestRegistryForPluginRegistry: (...args: unknown[]) =>
loadPluginManifestRegistry(...args),
loadPluginRegistrySnapshot: (...args: unknown[]) => loadPluginRegistrySnapshot(...args),
loadPluginRegistrySnapshotWithMetadata: (...args: unknown[]) => ({
source: "derived",
snapshot: loadPluginRegistrySnapshot(...args),
diagnostics: [],
}),
loadPluginRegistrySnapshotWithMetadata: (...args: unknown[]) =>
loadPluginRegistrySnapshotWithMetadata(...args),
listPluginContributionIds: (...args: unknown[]) => listPluginContributionIds(...args),
}));
vi.mock("../../config/plugin-auto-enable.js", () => ({
@@ -78,6 +76,11 @@ beforeEach(() => {
plugins: [],
diagnostics: [],
});
loadPluginRegistrySnapshotWithMetadata.mockImplementation((...args: unknown[]) => ({
snapshot: loadPluginRegistrySnapshot(...args),
source: "derived",
diagnostics: [],
}));
listPluginContributionIds.mockReturnValue([]);
listChatChannels.mockReturnValue([]);
});

View File

@@ -33,7 +33,9 @@ const mocks = vi.hoisted(() => ({
),
resolveInstalledManifestRegistryIndexFingerprint: vi.fn(() => "test-installed-index"),
loadBundledCapabilityRuntimeRegistry: vi.fn(),
loadPluginRegistrySnapshot: vi.fn<() => { plugins: Array<Record<string, unknown>> }>(() => ({
loadPluginRegistrySnapshot: vi.fn<
(_params?: unknown) => { plugins: Array<Record<string, unknown>> }
>(() => ({
plugins: [],
})),
withBundledPluginAllowlistCompat: vi.fn(
@@ -65,13 +67,21 @@ vi.mock("./manifest-registry-installed.js", () => ({
mocks.resolveInstalledManifestRegistryIndexFingerprint,
}));
vi.mock("./manifest-registry.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("./manifest-registry.js")>();
return {
...actual,
loadPluginManifestRegistry: mocks.loadPluginManifestRegistry,
};
});
vi.mock("./plugin-registry.js", async (importOriginal) => {
const actual = await importOriginal<typeof import("./plugin-registry.js")>();
return {
...actual,
loadPluginRegistrySnapshot: mocks.loadPluginRegistrySnapshot,
loadPluginRegistrySnapshotWithMetadata: (params?: { index?: unknown }) => {
const snapshot = (params?.index ?? mocks.loadPluginRegistrySnapshot()) as {
const snapshot = (params?.index ?? mocks.loadPluginRegistrySnapshot(params)) as {
plugins?: Array<Record<string, unknown>>;
};
return {
@@ -138,8 +148,6 @@ function expectBundledCompatLoadPath(params: {
expect.objectContaining({
config: params.cfg,
env: process.env,
includeDisabled: true,
index: expect.any(Object),
}),
);
expect(mocks.withBundledPluginEnablementCompat).toHaveBeenCalledWith({
@@ -1102,8 +1110,6 @@ describe("resolvePluginCapabilityProviders", () => {
expect.objectContaining({
config: {},
env: process.env,
includeDisabled: true,
index: expect.any(Object),
}),
);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith({
@@ -1230,8 +1236,6 @@ describe("resolvePluginCapabilityProviders", () => {
expect.objectContaining({
config: cfg,
env: process.env,
includeDisabled: true,
index: expect.any(Object),
}),
);
expect(mocks.withBundledPluginAllowlistCompat).toHaveBeenCalledWith({
@@ -1265,8 +1269,6 @@ describe("resolvePluginCapabilityProviders", () => {
expect.objectContaining({
config: {},
env: process.env,
includeDisabled: true,
index: expect.any(Object),
}),
);
expect(mocks.resolveRuntimePluginRegistry).toHaveBeenCalledWith();

View File

@@ -33,7 +33,9 @@ const mocks = vi.hoisted(() => ({
loadPluginManifestRegistry: vi.fn<(params?: Record<string, unknown>) => MockManifestRegistry>(
() => createEmptyMockManifestRegistry(),
),
loadPluginRegistrySnapshot: vi.fn<() => MockPluginIndex>(() => createMockPluginIndex([])),
loadPluginRegistrySnapshot: vi.fn<(_params?: unknown) => MockPluginIndex>(() =>
createMockPluginIndex([]),
),
loadPluginRegistrySnapshotWithMetadata: vi.fn((params?: { index?: MockPluginIndex }) => ({
source: params?.index ? "provided" : "derived",
snapshot: params?.index ?? createMockPluginIndex([]),
@@ -61,7 +63,7 @@ vi.mock("./plugin-registry.js", () => ({
vi.mock("./manifest-registry-installed.js", () => ({
loadPluginManifestRegistryForInstalledIndex: mocks.loadPluginManifestRegistry,
resolveInstalledManifestRegistryIndexFingerprint: () => "test-index",
resolveInstalledManifestRegistryIndexFingerprint: () => "test-installed-index",
}));
vi.mock("./bundled-compat.js", () => ({

View File

@@ -95,6 +95,18 @@ function createRuntimeWebFetchProvider() {
describe("resolvePluginWebFetchProviders", () => {
beforeAll(async () => {
vi.doMock("./plugin-registry.js", async () => {
const actual =
await vi.importActual<typeof import("./plugin-registry.js")>("./plugin-registry.js");
return {
...actual,
loadPluginRegistrySnapshotWithMetadata: () => ({
snapshot: { plugins: [], diagnostics: [] },
source: "derived",
diagnostics: [],
}),
};
});
loaderModule = await import("./loader.js");
manifestRegistryModule = await import("./manifest-registry.js");
webFetchProvidersSharedModule = await import("./web-fetch-providers.shared.js");
@@ -189,7 +201,7 @@ describe("resolvePluginWebFetchProviders", () => {
workspaceDir: DEFAULT_WORKSPACE,
env,
onlyPluginIds: ["firecrawl"],
cache: false,
cache: true,
activate: false,
});
const registry = createEmptyPluginRegistry();
@@ -226,7 +238,7 @@ describe("resolvePluginWebFetchProviders", () => {
workspaceDir: DEFAULT_WORKSPACE,
env,
onlyPluginIds: ["firecrawl"],
cache: false,
cache: true,
activate: false,
});
const registry = createEmptyPluginRegistry();

View File

@@ -304,7 +304,7 @@ function createActiveBraveRegistryFixture(params?: {
workspaceDir: DEFAULT_WEB_SEARCH_WORKSPACE,
env,
onlyPluginIds: ["brave"],
cache: false,
cache: true,
activate: false,
});
const registry = createEmptyPluginRegistry();
@@ -326,6 +326,16 @@ describe("resolvePluginWebSearchProviders", () => {
beforeAll(async () => {
loadPluginManifestRegistryMock = vi.fn<LoadPluginManifestRegistryForPluginRegistry>();
loadInstalledPluginManifestRegistryMock = vi.fn<LoadPluginManifestRegistryForInstalledIndex>();
vi.doMock("./manifest-registry.js", async () => {
const actual =
await vi.importActual<typeof import("./manifest-registry.js")>("./manifest-registry.js");
return {
...actual,
loadPluginManifestRegistry: (
...args: Parameters<LoadPluginManifestRegistryForPluginRegistry>
) => loadPluginManifestRegistryMock(...args),
};
});
vi.doMock("./plugin-registry.js", async () => {
const actual =
await vi.importActual<typeof import("./plugin-registry.js")>("./plugin-registry.js");