test: tighten messaging helper assertions · openclaw/openclaw@45ef481
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -71,7 +71,6 @@ describe("mattermost setup contract", () => {
|
71 | 71 | expectedAccountId: "default", |
72 | 72 | assertPatchedConfig: (cfg) => { |
73 | 73 | const mattermostConfig = cfg.channels?.mattermost; |
74 | | -expect(mattermostConfig).toBeDefined(); |
75 | 74 | if (!mattermostConfig) { |
76 | 75 | throw new Error("expected Mattermost config patch"); |
77 | 76 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -31,15 +31,18 @@ describe("mattermost doctor", () => {
|
31 | 31 | }); |
32 | 32 | |
33 | 33 | const mattermostConfig = result.config.channels?.mattermost; |
34 | | -expect(mattermostConfig).toBeDefined(); |
35 | 34 | if (!mattermostConfig) { |
36 | 35 | throw new Error("expected normalized Mattermost config"); |
37 | 36 | } |
38 | 37 | expect(mattermostConfig.network).toEqual({ |
39 | 38 | dangerouslyAllowPrivateNetwork: true, |
40 | 39 | }); |
41 | | -const workAccount = mattermostConfig.accounts?.work as { network?: Record<string, unknown> }; |
42 | | -expect(workAccount).toBeDefined(); |
| 40 | +const workAccount = mattermostConfig.accounts?.work as |
| 41 | +| { network?: Record<string, unknown> } |
| 42 | +| undefined; |
| 43 | +if (!workAccount) { |
| 44 | +throw new Error("expected Mattermost work account config"); |
| 45 | +} |
43 | 46 | expect(workAccount.network).toEqual({ |
44 | 47 | dangerouslyAllowPrivateNetwork: false, |
45 | 48 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -277,12 +277,10 @@ describe("updateMattermostPost", () => {
|
277 | 277 | const { calls } = await updatePostAndCapture({ message: "Updated" }); |
278 | 278 | |
279 | 279 | const firstCall = calls[0]; |
280 | | -expect(firstCall).toBeDefined(); |
281 | 280 | if (!firstCall) { |
282 | 281 | throw new Error("expected Mattermost update post request"); |
283 | 282 | } |
284 | 283 | expect(firstCall.url).toContain("/posts/post1"); |
285 | | -expect(firstCall.init).toBeDefined(); |
286 | 284 | if (!firstCall.init) { |
287 | 285 | throw new Error("expected Mattermost update post request init"); |
288 | 286 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -60,12 +60,10 @@ describe("Mattermost model picker", () => {
|
60 | 60 | expect(view.text).toContain("Browse keeps the current runtime"); |
61 | 61 | expect(view.text).toContain("/oc_model <provider/model> --runtime <runtime>"); |
62 | 62 | const firstRow = view.buttons[0]; |
63 | | -expect(firstRow).toBeDefined(); |
64 | 63 | if (!firstRow) { |
65 | 64 | throw new Error("expected Mattermost model picker button row"); |
66 | 65 | } |
67 | 66 | const browseButton = firstRow[0]; |
68 | | -expect(browseButton).toBeDefined(); |
69 | 67 | if (!browseButton) { |
70 | 68 | throw new Error("expected Mattermost browse providers button"); |
71 | 69 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -131,7 +131,6 @@ describe("slash-commands", () => {
|
131 | 131 | |
132 | 132 | expect(result).toHaveLength(1); |
133 | 133 | const firstCommand = result[0]; |
134 | | -expect(firstCommand).toBeDefined(); |
135 | 134 | if (!firstCommand) { |
136 | 135 | throw new Error("expected Mattermost slash command result"); |
137 | 136 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -392,7 +392,6 @@ describe("mattermost setup", () => {
|
392 | 392 | ); |
393 | 393 | expect(textMessages).toEqual(["Enter Mattermost bot token", "Enter Mattermost base URL"]); |
394 | 394 | const mattermostConfig = result.cfg.channels?.mattermost; |
395 | | -expect(mattermostConfig).toBeDefined(); |
396 | 395 | if (!mattermostConfig) { |
397 | 396 | throw new Error("expected Mattermost config"); |
398 | 397 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -122,7 +122,6 @@ describe("Synology Chat TLS verification defaults", () => {
|
122 | 122 | await settleTimers(invoke()); |
123 | 123 | const httpsRequest = vi.mocked(https.request); |
124 | 124 | const firstCall = httpsRequest.mock.calls[0]; |
125 | | -expect(firstCall).toBeDefined(); |
126 | 125 | if (!firstCall) { |
127 | 126 | throw new Error("expected Synology Chat HTTPS request"); |
128 | 127 | } |
@@ -159,7 +158,6 @@ describe("sendMessage", () => {
|
159 | 158 | await settleTimers(sendMessage("https://nas.example.com/incoming", "Hello", undefined, true)); |
160 | 159 | const httpsRequest = vi.mocked(https.request); |
161 | 160 | const firstCall = httpsRequest.mock.calls[0]; |
162 | | -expect(firstCall).toBeDefined(); |
163 | 161 | if (!firstCall) { |
164 | 162 | throw new Error("expected Synology Chat HTTPS request"); |
165 | 163 | } |
@@ -387,7 +385,6 @@ describe("fetchChatUsers", () => {
|
387 | 385 | |
388 | 386 | const httpsGet = vi.mocked(https.get); |
389 | 387 | const firstCall = httpsGet.mock.calls[0]; |
390 | | -expect(firstCall).toBeDefined(); |
391 | 388 | if (!firstCall) { |
392 | 389 | throw new Error("expected Synology Chat HTTPS get"); |
393 | 390 | } |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,7 +9,6 @@ import {
|
9 | 9 | describe("vitest process group helpers", () => { |
10 | 10 | function getListenerSet(listeners: Map<string, Set<() => void>>, event: string) { |
11 | 11 | const set = listeners.get(event); |
12 | | -expect(set).toBeDefined(); |
13 | 12 | if (!set) { |
14 | 13 | throw new Error(`expected ${event} listener set`); |
15 | 14 | } |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。