

























@@ -165,6 +165,16 @@ async function readSchemaNodes() {
165165return { channelProps, entryProps };
166166}
167167168+function getManifestRegistryLoadArg(index = 0): Record<string, unknown> | undefined {
169+const arg = mockLoadPluginManifestRegistry.mock.calls[index]?.[0];
170+return arg && typeof arg === "object" ? (arg as Record<string, unknown>) : undefined;
171+}
172+173+function getCurrentMetadataSnapshotArg(index = 0): Record<string, unknown> | undefined {
174+const arg = mockGetCurrentPluginMetadataSnapshot.mock.calls[index]?.[0];
175+return arg && typeof arg === "object" ? (arg as Record<string, unknown>) : undefined;
176+}
177+168178beforeAll(async () => {
169179({ readBestEffortRuntimeConfigSchema, loadGatewayRuntimeConfigSchema } =
170180await import("./runtime-schema.js"));
@@ -191,15 +201,11 @@ describe("readBestEffortRuntimeConfigSchema", () => {
191201192202const { channelProps, entryProps } = await readSchemaNodes();
193203194-expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
195-expect.objectContaining({
196-config: { plugins: { entries: { demo: { enabled: true } } } },
197-}),
198-);
199-expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty("cache", false);
200-expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty(
201-"bundledChannelConfigCollector",
202-);
204+expect(mockLoadPluginManifestRegistry).toHaveBeenCalledTimes(1);
205+const loadArg = getManifestRegistryLoadArg();
206+expect(loadArg?.config).toEqual({ plugins: { entries: { demo: { enabled: true } } } });
207+expect(loadArg).not.toHaveProperty("cache", false);
208+expect(loadArg).not.toHaveProperty("bundledChannelConfigCollector");
203209expect(channelProps).toHaveProperty("telegram");
204210expect(channelProps).toHaveProperty("matrix");
205211expect(entryProps).toHaveProperty("demo");
@@ -210,15 +216,11 @@ describe("readBestEffortRuntimeConfigSchema", () => {
210216211217const { channelProps, entryProps } = await readSchemaNodes();
212218213-expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
214-expect.objectContaining({
215-config: { plugins: { enabled: true } },
216-}),
217-);
218-expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty("cache", false);
219-expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty(
220-"bundledChannelConfigCollector",
221-);
219+expect(mockLoadPluginManifestRegistry).toHaveBeenCalledTimes(1);
220+const loadArg = getManifestRegistryLoadArg();
221+expect(loadArg?.config).toEqual({ plugins: { enabled: true } });
222+expect(loadArg).not.toHaveProperty("cache", false);
223+expect(loadArg).not.toHaveProperty("bundledChannelConfigCollector");
222224expect(channelProps).toHaveProperty("telegram");
223225expect(channelProps).toHaveProperty("slack");
224226expect(entryProps?.demo).toBeUndefined();
@@ -238,14 +240,10 @@ describe("loadGatewayRuntimeConfigSchema", () => {
238240const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
239241const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
240242241-expect(mockLoadPluginManifestRegistry).toHaveBeenCalledWith(
242-expect.objectContaining({
243-config: { plugins: { entries: { demo: { enabled: true } } } },
244-}),
245-);
246-expect(mockLoadPluginManifestRegistry.mock.calls[0]?.[0]).not.toHaveProperty(
247-"bundledChannelConfigCollector",
248-);
243+expect(mockLoadPluginManifestRegistry).toHaveBeenCalledTimes(1);
244+const loadArg = getManifestRegistryLoadArg();
245+expect(loadArg?.config).toEqual({ plugins: { entries: { demo: { enabled: true } } } });
246+expect(loadArg).not.toHaveProperty("bundledChannelConfigCollector");
249247expect(channelProps).toHaveProperty("telegram");
250248expect(channelProps).toHaveProperty("matrix");
251249});
@@ -288,11 +286,9 @@ describe("loadGatewayRuntimeConfigSchema", () => {
288286const channelsNode = schema.properties?.channels as Record<string, unknown> | undefined;
289287const channelProps = channelsNode?.properties as Record<string, unknown> | undefined;
290288291-expect(mockGetCurrentPluginMetadataSnapshot).toHaveBeenCalledWith(
292-expect.objectContaining({
293-config: { plugins: { entries: { demo: { enabled: true } } } },
294-}),
295-);
289+expect(mockGetCurrentPluginMetadataSnapshot).toHaveBeenCalledTimes(1);
290+const metadataArg = getCurrentMetadataSnapshotArg();
291+expect(metadataArg?.config).toEqual({ plugins: { entries: { demo: { enabled: true } } } });
296292expect(mockLoadPluginManifestRegistry).not.toHaveBeenCalled();
297293expect(channelProps).toHaveProperty("telegram");
298294expect(JSON.stringify(channelProps?.telegram)).toContain("botToken");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。