test: dedupe config compatibility fixtures

This commit is contained in:
Peter Steinberger
2026-03-26 15:44:25 +00:00
parent 6bdf5e5634
commit 4ed5895637
3 changed files with 82 additions and 148 deletions

View File

@@ -38,6 +38,19 @@ function makeSnapshot(params: { valid: boolean; config?: OpenClawConfig }): Conf
};
}
async function readSchemaNodes() {
const { readBestEffortRuntimeConfigSchema } = await import("./runtime-schema.js");
const result = await readBestEffortRuntimeConfigSchema();
const schema = result.schema as { properties?: Record<string, unknown> };
const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
const pluginsNode = schema.properties?.plugins as Record<string, unknown> | undefined;
const pluginProps = pluginsNode?.properties as Record<string, unknown> | undefined;
const entriesNode = pluginProps?.entries as Record<string, unknown> | undefined;
const entryProps = entriesNode?.properties as Record<string, unknown> | undefined;
return { channelProps, entryProps };
}
describe("readBestEffortRuntimeConfigSchema", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -90,15 +103,7 @@ describe("readBestEffortRuntimeConfigSchema", () => {
channelSetups: [],
});
const { readBestEffortRuntimeConfigSchema } = await import("./runtime-schema.js");
const result = await readBestEffortRuntimeConfigSchema();
const schema = result.schema as { properties?: Record<string, unknown> };
const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
const pluginsNode = schema.properties?.plugins as Record<string, unknown> | undefined;
const pluginProps = pluginsNode?.properties as Record<string, unknown> | undefined;
const entriesNode = pluginProps?.entries as Record<string, unknown> | undefined;
const entryProps = entriesNode?.properties as Record<string, unknown> | undefined;
const { channelProps, entryProps } = await readSchemaNodes();
expect(mockLoadOpenClawPlugins).toHaveBeenCalledWith(
expect.objectContaining({
@@ -157,15 +162,7 @@ describe("readBestEffortRuntimeConfigSchema", () => {
],
});
const { readBestEffortRuntimeConfigSchema } = await import("./runtime-schema.js");
const result = await readBestEffortRuntimeConfigSchema();
const schema = result.schema as { properties?: Record<string, unknown> };
const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
const pluginsNode = schema.properties?.plugins as Record<string, unknown> | undefined;
const pluginProps = pluginsNode?.properties as Record<string, unknown> | undefined;
const entriesNode = pluginProps?.entries as Record<string, unknown> | undefined;
const entryProps = entriesNode?.properties as Record<string, unknown> | undefined;
const { channelProps, entryProps } = await readSchemaNodes();
expect(mockLoadOpenClawPlugins).toHaveBeenCalledWith(
expect.objectContaining({