test: tighten small command assertions · openclaw/openclaw@0311fe9
steipete
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -34,6 +34,15 @@ const authIndex = {
|
34 | 34 | allowsProviderAuthAvailabilityFallback: () => false, |
35 | 35 | }; |
36 | 36 | |
| 37 | +function requireOnlyRow(rows: ModelRow[]): ModelRow { |
| 38 | +expect(rows).toHaveLength(1); |
| 39 | +const row = rows[0]; |
| 40 | +if (!row) { |
| 41 | +throw new Error("expected one model row"); |
| 42 | +} |
| 43 | +return row; |
| 44 | +} |
| 45 | + |
37 | 46 | describe("appendProviderCatalogRows", () => { |
38 | 47 | it("can skip runtime model-suppression hooks for provider-catalog fast paths", async () => { |
39 | 48 | const rows: ModelRow[] = []; |
@@ -64,13 +73,10 @@ describe("appendProviderCatalogRows", () => {
|
64 | 73 | models: { providers: {} }, |
65 | 74 | }, |
66 | 75 | }); |
67 | | -expect(rows).toMatchObject([ |
68 | | -{ |
69 | | -key: "codex/gpt-5.5", |
70 | | -available: true, |
71 | | -missing: false, |
72 | | -}, |
73 | | -]); |
| 76 | +const row = requireOnlyRow(rows); |
| 77 | +expect(row.key).toBe("codex/gpt-5.5"); |
| 78 | +expect(row.available).toBe(true); |
| 79 | +expect(row.missing).toBe(false); |
74 | 80 | }); |
75 | 81 | |
76 | 82 | it("applies manifest suppression when runtime model-suppression hooks are skipped", async () => { |
@@ -163,12 +169,9 @@ describe("appendProviderCatalogRows", () => {
|
163 | 169 | }, |
164 | 170 | }); |
165 | 171 | |
166 | | -expect(rows).toMatchObject([ |
167 | | -{ |
168 | | -key: "openai/gpt-5.5", |
169 | | -available: true, |
170 | | -tags: ["configured"], |
171 | | -}, |
172 | | -]); |
| 172 | +const row = requireOnlyRow(rows); |
| 173 | +expect(row.key).toBe("openai/gpt-5.5"); |
| 174 | +expect(row.available).toBe(true); |
| 175 | +expect(row.tags).toEqual(["configured"]); |
173 | 176 | }); |
174 | 177 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -26,11 +26,12 @@ describe("runOpenAIOAuthTlsPreflight", () => {
|
26 | 26 | throw new TypeError("fetch failed", { cause }); |
27 | 27 | }) as unknown as typeof fetch; |
28 | 28 | const result = await runOpenAIOAuthTlsPreflight({ fetchImpl: tlsFetchImpl, timeoutMs: 20 }); |
29 | | -expect(result).toMatchObject({ |
30 | | -ok: false, |
31 | | -kind: "tls-cert", |
32 | | -code: "UNABLE_TO_GET_ISSUER_CERT_LOCALLY", |
33 | | -}); |
| 29 | +expect(result.ok).toBe(false); |
| 30 | +if (result.ok) { |
| 31 | +throw new Error("expected TLS certificate preflight failure"); |
| 32 | +} |
| 33 | +expect(result.kind).toBe("tls-cert"); |
| 34 | +expect(result.code).toBe("UNABLE_TO_GET_ISSUER_CERT_LOCALLY"); |
34 | 35 | }); |
35 | 36 | |
36 | 37 | it("keeps generic TLS transport failures in network classification", async () => { |
@@ -45,10 +46,11 @@ describe("runOpenAIOAuthTlsPreflight", () => {
|
45 | 46 | fetchImpl: networkFetchImpl, |
46 | 47 | timeoutMs: 20, |
47 | 48 | }); |
48 | | -expect(result).toMatchObject({ |
49 | | -ok: false, |
50 | | -kind: "network", |
51 | | -}); |
| 49 | +expect(result.ok).toBe(false); |
| 50 | +if (result.ok) { |
| 51 | +throw new Error("expected network preflight failure"); |
| 52 | +} |
| 53 | +expect(result.kind).toBe("network"); |
52 | 54 | }); |
53 | 55 | }); |
54 | 56 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -190,9 +190,7 @@ describe("onboard-search provider resolution", () => {
|
190 | 190 | provider: "default", |
191 | 191 | id: "CUSTOM_SEARCH_API_KEY", |
192 | 192 | }); |
193 | | -expect(notes.map((note) => note.message)).toEqual( |
194 | | -expect.arrayContaining([expect.stringContaining("CUSTOM_SEARCH_API_KEY")]), |
195 | | -); |
| 193 | +expect(notes.some((note) => note.message.includes("CUSTOM_SEARCH_API_KEY"))).toBe(true); |
196 | 194 | }); |
197 | 195 | |
198 | 196 | it("does not treat hard-disabled bundled providers as selectable credentials", () => { |
@@ -251,9 +249,7 @@ describe("onboard-search provider resolution", () => {
|
251 | 249 | |
252 | 250 | expect(result.tools?.web?.search?.provider).toBe("duckduckgo"); |
253 | 251 | expect(result.plugins?.entries?.duckduckgo?.enabled).toBe(true); |
254 | | -expect(notes).toEqual( |
255 | | -expect.arrayContaining([expect.stringContaining("works without an API key")]), |
256 | | -); |
| 252 | +expect(notes.some((message) => message.includes("works without an API key"))).toBe(true); |
257 | 253 | }); |
258 | 254 | |
259 | 255 | it("uses the runtime onboarding search surface when no config is present", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -45,7 +45,7 @@ describe("sessionsCommand", () => {
|
45 | 45 | |
46 | 46 | fs.rmSync(store); |
47 | 47 | |
48 | | -expect(logs).toEqual(expect.arrayContaining([expect.stringContaining("Tokens (ctx %")])); |
| 48 | +expect(logs.some((line) => line.includes("Tokens (ctx %"))).toBe(true); |
49 | 49 | |
50 | 50 | const row = logs.find((line) => line.includes("+15555550123")) ?? ""; |
51 | 51 | expect(row).toContain("2.0k/32k (6%)"); |
@@ -82,7 +82,7 @@ describe("sessionsCommand", () => {
|
82 | 82 | |
83 | 83 | fs.rmSync(store); |
84 | 84 | |
85 | | -expect(logs).toEqual(expect.arrayContaining([expect.stringContaining("Runtime")])); |
| 85 | +expect(logs.some((line) => line.includes("Runtime"))).toBe(true); |
86 | 86 | |
87 | 87 | const row = logs.find((line) => line.includes("agent:main:main")) ?? ""; |
88 | 88 | expect(row).toContain("claude-opus-4-7"); |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。