test: dedupe plugin runtime registry suites

This commit is contained in:
Peter Steinberger
2026-03-28 04:43:25 +00:00
parent 25fea00bc7
commit fc84dd398b
4 changed files with 75 additions and 40 deletions

View File

@@ -49,6 +49,14 @@ function expectMemoryRuntimeLoaded(autoEnabledConfig: unknown) {
});
}
function setAutoEnabledMemoryRuntime() {
const { rawConfig, autoEnabledConfig } = createMemoryAutoEnableFixture();
const runtime = createMemoryRuntimeFixture();
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
getMemoryRuntimeMock.mockReturnValueOnce(undefined).mockReturnValue(runtime);
return { rawConfig, autoEnabledConfig, runtime };
}
describe("memory runtime auto-enable loading", () => {
beforeEach(async () => {
vi.resetModules();
@@ -66,17 +74,33 @@ describe("memory runtime auto-enable loading", () => {
} = await import("./memory-runtime.js"));
});
it("loads memory runtime from the auto-enabled config snapshot", async () => {
const { rawConfig, autoEnabledConfig } = createMemoryAutoEnableFixture();
const runtime = createMemoryRuntimeFixture();
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
getMemoryRuntimeMock.mockReturnValueOnce(undefined).mockReturnValue(runtime);
it.each([
{
name: "loads memory runtime from the auto-enabled config snapshot",
run: async (rawConfig: unknown) =>
getActiveMemorySearchManager({
cfg: rawConfig as never,
agentId: "main",
}),
expectedResult: undefined,
},
{
name: "reuses the same auto-enabled load path for backend config resolution",
run: async (rawConfig: unknown) =>
resolveActiveMemoryBackendConfig({
cfg: rawConfig as never,
agentId: "main",
}),
expectedResult: { backend: "builtin" },
},
] as const)("$name", async ({ run, expectedResult }) => {
const { rawConfig, autoEnabledConfig } = setAutoEnabledMemoryRuntime();
await getActiveMemorySearchManager({
cfg: rawConfig as never,
agentId: "main",
});
const result = await run(rawConfig);
if (expectedResult !== undefined) {
expect(result).toEqual(expectedResult);
}
expect(applyPluginAutoEnableMock).toHaveBeenCalledWith({
config: rawConfig,
env: process.env,
@@ -84,21 +108,6 @@ describe("memory runtime auto-enable loading", () => {
expectMemoryRuntimeLoaded(autoEnabledConfig);
});
it("reuses the same auto-enabled load path for backend config resolution", () => {
const { rawConfig, autoEnabledConfig } = createMemoryAutoEnableFixture();
const runtime = createMemoryRuntimeFixture();
applyPluginAutoEnableMock.mockReturnValue({ config: autoEnabledConfig, changes: [] });
getMemoryRuntimeMock.mockReturnValueOnce(undefined).mockReturnValue(runtime);
const result = resolveActiveMemoryBackendConfig({
cfg: rawConfig as never,
agentId: "main",
});
expect(result).toEqual({ backend: "builtin" });
expectMemoryRuntimeLoaded(autoEnabledConfig);
});
it("does not bootstrap the memory runtime just to close managers", async () => {
const rawConfig = {
plugins: {},