
























@@ -71,6 +71,22 @@ function configureScanStatus(
7171mocks.callGateway.mockResolvedValue(null);
7272}
737374+function firstCallArg(mock: { mock: { calls: unknown[][] } }, label: string): unknown {
75+const arg = mock.mock.calls.at(0)?.at(0);
76+if (arg === undefined) {
77+throw new Error(`expected ${label}`);
78+}
79+return arg;
80+}
81+82+function firstBuildChannelsTableCall(): unknown[] {
83+const call = mocks.buildChannelsTable.mock.calls.at(0);
84+if (!call) {
85+throw new Error("expected buildChannelsTable call");
86+}
87+return call;
88+}
89+7490describe("scanStatus", () => {
7591it("passes sourceConfig into buildChannelsTable for summary-mode status output", async () => {
7692const sourceConfig = createStatusScanConfig({
@@ -90,7 +106,7 @@ describe("scanStatus", () => {
90106await scanStatus({ json: false }, {} as never);
9110792108expect(mocks.buildChannelsTable).toHaveBeenCalledOnce();
93-expect(mocks.buildChannelsTable.mock.calls[0]).toStrictEqual([
109+expect(firstBuildChannelsTableCall()).toStrictEqual([
94110resolvedConfig,
95111{
96112showSecrets: true,
@@ -128,7 +144,7 @@ describe("scanStatus", () => {
128144}),
129145).toBe(false);
130146expect(mocks.buildChannelsTable).toHaveBeenCalledOnce();
131-expect(mocks.buildChannelsTable.mock.calls[0]).toStrictEqual([
147+expect(firstBuildChannelsTableCall()).toStrictEqual([
132148cfg,
133149{
134150showSecrets: true,
@@ -167,7 +183,7 @@ describe("scanStatus", () => {
167183await scanStatus({ json: false, deep: true, timeoutMs: 5000 }, {} as never);
168184169185expect(mocks.callGateway).toHaveBeenCalledOnce();
170-expect(mocks.callGateway.mock.calls[0]?.[0]).toStrictEqual({
186+expect(firstCallArg(mocks.callGateway, "callGateway args")).toStrictEqual({
171187config: cfg,
172188method: "channels.status",
173189params: {
@@ -177,7 +193,7 @@ describe("scanStatus", () => {
177193timeoutMs: 2500,
178194});
179195expect(mocks.buildChannelsTable).toHaveBeenCalledOnce();
180-expect(mocks.buildChannelsTable.mock.calls[0]).toStrictEqual([
196+expect(firstBuildChannelsTableCall()).toStrictEqual([
181197cfg,
182198{
183199showSecrets: true,
@@ -276,7 +292,7 @@ describe("scanStatus", () => {
276292await scanStatus({ json: true }, {} as never);
277293278294expect(mocks.getMemorySearchManager).toHaveBeenCalledOnce();
279-expect(mocks.getMemorySearchManager.mock.calls[0]?.[0]).toStrictEqual({
295+expect(firstCallArg(mocks.getMemorySearchManager, "memory search manager args")).toStrictEqual({
280296cfg: createStatusMemorySearchConfig(),
281297agentId: "main",
282298purpose: "status",
@@ -305,7 +321,7 @@ describe("scanStatus", () => {
305321// Verify plugin logs were routed to stderr during loading and restored after
306322expect(loggingStateRef.forceConsoleToStderr).toBe(false);
307323expect(mocks.probeGateway).toHaveBeenCalledOnce();
308-expect(mocks.probeGateway.mock.calls[0]?.[0]).toStrictEqual({
324+expect(firstCallArg(mocks.probeGateway, "probeGateway args")).toStrictEqual({
309325url: "ws://127.0.0.1:18789",
310326auth: {},
311327preauthHandshakeTimeoutMs: undefined,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。