test: guard doctor command mock calls · openclaw/openclaw@7a8d86b
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -100,7 +100,7 @@ describe("maybeInstallDaemon", () => {
|
100 | 100 | |
101 | 101 | expect(resolveGatewayInstallToken).toHaveBeenCalledTimes(1); |
102 | 102 | expect(buildGatewayInstallPlan).toHaveBeenCalledTimes(1); |
103 | | -expect("token" in buildGatewayInstallPlan.mock.calls[0][0]).toBe(false); |
| 103 | +expect("token" in buildGatewayInstallPlan.mock.calls.at(0)?.[0]).toBe(false); |
104 | 104 | expect(serviceInstall).toHaveBeenCalledTimes(1); |
105 | 105 | }); |
106 | 106 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -166,7 +166,7 @@ describe("dashboardCommand", () => {
|
166 | 166 | // hint string is written to runtime.log, which flows into the same |
167 | 167 | // console-captured log file readable by operator.read-scoped devices. |
168 | 168 | expect(formatControlUiSshHintMock).toHaveBeenCalledWith({ port: 18789, basePath: undefined }); |
169 | | -const [sshHintOptions] = formatControlUiSshHintMock.mock.calls[0] ?? []; |
| 169 | +const [sshHintOptions] = formatControlUiSshHintMock.mock.calls.at(0) ?? []; |
170 | 170 | expect(sshHintOptions).not.toHaveProperty("token"); |
171 | 171 | |
172 | 172 | // Double-check: no logged line contains the secret. |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -52,7 +52,7 @@ describe("noteBootstrapFileSize", () => {
|
52 | 52 | }); |
53 | 53 | await noteBootstrapFileSize({} as OpenClawConfig); |
54 | 54 | expect(note).toHaveBeenCalledTimes(1); |
55 | | -const [message, title] = note.mock.calls[0] ?? []; |
| 55 | +const [message, title] = note.mock.calls.at(0) ?? []; |
56 | 56 | expect(title).toBe("Bootstrap file size"); |
57 | 57 | expect(message).toBe( |
58 | 58 | [ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -307,7 +307,7 @@ describe("maybeRepairGatewayDaemon", () => {
|
307 | 307 | }); |
308 | 308 | |
309 | 309 | expect(readGatewayRestartHandoffSync).toHaveBeenCalledOnce(); |
310 | | -const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls[0] as unknown as [ |
| 310 | +const [handoffEnv] = readGatewayRestartHandoffSync.mock.calls.at(0) as unknown as [ |
311 | 311 | { OPENCLAW_STATE_DIR?: string; OPENCLAW_CONFIG_PATH?: string }, |
312 | 312 | ]; |
313 | 313 | expect(handoffEnv?.OPENCLAW_STATE_DIR).toBe("/tmp/openclaw-service"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -306,7 +306,7 @@ describe("doctor repair sequencing", () => {
|
306 | 306 | |
307 | 307 | expect(events).toEqual(["bundled-shadow-cleanup", "openclaw-peer-links", "missing-installs"]); |
308 | 308 | expect(mocks.maybeRepairStaleManagedNpmBundledPlugins).toHaveBeenCalledOnce(); |
309 | | -const cleanupCall = mocks.maybeRepairStaleManagedNpmBundledPlugins.mock.calls[0]?.[0]; |
| 309 | +const cleanupCall = mocks.maybeRepairStaleManagedNpmBundledPlugins.mock.calls.at(0)?.[0]; |
310 | 310 | expect(cleanupCall?.config.plugins?.entries?.["google-meet"]).toEqual({ enabled: true }); |
311 | 311 | expect(cleanupCall?.prompter).toEqual({ shouldRepair: true }); |
312 | 312 | expect(mocks.maybeRepairManagedNpmOpenClawPeerLinks).toHaveBeenCalledWith( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -305,7 +305,7 @@ describe("channel doctor compatibility mutations", () => {
|
305 | 305 | cfg, |
306 | 306 | READ_ONLY_CHANNEL_DOCTOR_OPTIONS, |
307 | 307 | ); |
308 | | -expect(collectEmptyAllowlistExtraWarnings.mock.calls[0]?.[0]).not.toHaveProperty("cfg"); |
| 308 | +expect(collectEmptyAllowlistExtraWarnings.mock.calls.at(0)?.[0]).not.toHaveProperty("cfg"); |
309 | 309 | }); |
310 | 310 | |
311 | 311 | it("reuses empty allowlist doctor entries across per-account hooks", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -83,7 +83,7 @@ describe("doctor empty allowlist policy scan", () => {
|
83 | 83 | |
84 | 84 | expect(warnings).toEqual(["extra:channels.signal"]); |
85 | 85 | expect(extraWarningsForAccount).toHaveBeenCalledTimes(1); |
86 | | -const [warningOptions] = extraWarningsForAccount.mock.calls[0] ?? []; |
| 86 | +const [warningOptions] = extraWarningsForAccount.mock.calls.at(0) ?? []; |
87 | 87 | expect(warningOptions?.prefix).toBe("channels.signal"); |
88 | 88 | }); |
89 | 89 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -88,7 +88,7 @@ describe("flows commands", () => {
|
88 | 88 | const runtime = createRuntime(); |
89 | 89 | await flowsListCommand({ json: true, status: "blocked" }, runtime); |
90 | 90 | |
91 | | -const payload = JSON.parse(String(vi.mocked(runtime.log).mock.calls[0]?.[0])); |
| 91 | +const payload = JSON.parse(String(vi.mocked(runtime.log).mock.calls.at(0)?.[0])); |
92 | 92 | |
93 | 93 | expect(payload).toStrictEqual({ |
94 | 94 | count: 1, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -57,7 +57,7 @@ describe("models/shared", () => {
|
57 | 57 | })); |
58 | 58 | |
59 | 59 | expect(mocks.replaceConfigFile).toHaveBeenCalledOnce(); |
60 | | -const [replaceParams] = mocks.replaceConfigFile.mock.calls[0] ?? []; |
| 60 | +const [replaceParams] = mocks.replaceConfigFile.mock.calls.at(0) ?? []; |
61 | 61 | expect(replaceParams?.nextConfig.update).toEqual({ channel: "beta" }); |
62 | 62 | expect(replaceParams?.baseHash).toBe("config-1"); |
63 | 63 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -44,7 +44,7 @@ describe("noteOpenAIOAuthTlsPrerequisites", () => {
|
44 | 44 | } |
45 | 45 | |
46 | 46 | expect(note).toHaveBeenCalledTimes(1); |
47 | | -const [message, title] = note.mock.calls[0] as [string, string]; |
| 47 | +const [message, title] = note.mock.calls.at(0) as [string, string]; |
48 | 48 | expect(title).toBe("OAuth TLS prerequisites"); |
49 | 49 | expect(message).toContain("brew postinstall ca-certificates"); |
50 | 50 | }); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。