test: tighten gateway live assertions · openclaw/openclaw@552f088
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -461,11 +461,13 @@ describeLive("gateway live (cli backend)", () => {
|
461 | 461 | } else { |
462 | 462 | expect(text).toContain(`CLI-BACKEND-${nonce}`); |
463 | 463 | } |
464 | | -expect( |
| 464 | +const injectedFileNames = |
465 | 465 | resultWithMeta.meta?.systemPromptReport?.injectedWorkspaceFiles?.map( |
466 | 466 | (entry) => entry.name, |
467 | | -) ?? [], |
468 | | -).toEqual(expect.arrayContaining(bootstrapWorkspace?.expectedInjectedFiles ?? [])); |
| 467 | +) ?? []; |
| 468 | +for (const expectedFile of bootstrapWorkspace?.expectedInjectedFiles ?? []) { |
| 469 | +expect(injectedFileNames).toContain(expectedFile); |
| 470 | +} |
469 | 471 | } |
470 | 472 | |
471 | 473 | if (modelSwitchTarget) { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -1358,10 +1358,8 @@ describe("sanitizeAuthProfileStoreForLiveGateway", () => {
|
1358 | 1358 | try { |
1359 | 1359 | const sanitized = sanitizeAuthProfileStoreForLiveGateway(store); |
1360 | 1360 | expect(sanitized.profiles.openaiProfile).toBeUndefined(); |
1361 | | -expect(sanitized.profiles.codexProfile).toMatchObject({ |
1362 | | -type: "oauth", |
1363 | | -provider: "openai-codex", |
1364 | | -}); |
| 1361 | +expect(sanitized.profiles.codexProfile?.type).toBe("oauth"); |
| 1362 | +expect(sanitized.profiles.codexProfile?.provider).toBe("openai-codex"); |
1365 | 1363 | expect(sanitized.order).toEqual({ "openai-codex": ["codexProfile"] }); |
1366 | 1364 | expect(sanitized.lastGood).toEqual({ "openai-codex": "codexProfile" }); |
1367 | 1365 | expect(sanitized.usageStats).toEqual({ codexProfile: { lastUsed: 2 } }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -152,10 +152,8 @@ async function approveTrajectoryExport(client: GatewayClient): Promise<string> {
|
152 | 152 | const approval = approvals.find((entry) => |
153 | 153 | entry.request?.command?.includes("sessions export-trajectory"), |
154 | 154 | ); |
155 | | -expect(approval).toMatchObject({ |
156 | | -id: expect.any(String), |
157 | | -request: { command: expect.stringContaining("sessions export-trajectory") }, |
158 | | -}); |
| 155 | +expect(typeof approval?.id).toBe("string"); |
| 156 | +expect(approval?.request?.command).toContain("sessions export-trajectory"); |
159 | 157 | if (!approval?.id) { |
160 | 158 | throw new Error("expected trajectory export approval id"); |
161 | 159 | } |
@@ -285,17 +283,18 @@ describeLive("gateway live trajectory export", () => {
|
285 | 283 | if (finalText) { |
286 | 284 | expect(finalText).toContain("Approve once"); |
287 | 285 | } |
288 | | -expect(await listDirectoryNames(bundleDir)).toEqual( |
289 | | -expect.arrayContaining([ |
290 | | -"artifacts.json", |
291 | | -"events.jsonl", |
292 | | -"manifest.json", |
293 | | -"metadata.json", |
294 | | -"prompts.json", |
295 | | -"session.jsonl", |
296 | | -"tools.json", |
297 | | -]), |
298 | | -); |
| 286 | +const bundleNames = await listDirectoryNames(bundleDir); |
| 287 | +for (const expectedName of [ |
| 288 | +"artifacts.json", |
| 289 | +"events.jsonl", |
| 290 | +"manifest.json", |
| 291 | +"metadata.json", |
| 292 | +"prompts.json", |
| 293 | +"session.jsonl", |
| 294 | +"tools.json", |
| 295 | +]) { |
| 296 | +expect(bundleNames).toContain(expectedName); |
| 297 | +} |
299 | 298 | expect(beforeExport.has("bundle")).toBe(false); |
300 | 299 | |
301 | 300 | const manifest = JSON.parse( |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -107,9 +107,7 @@ function expectPluginApprovalId(value: unknown, label: string): string {
|
107 | 107 | expect(uuid).toHaveLength(36); |
108 | 108 | expect(uuid.split("-").map((part) => part.length)).toEqual([8, 4, 4, 4, 12]); |
109 | 109 | expect( |
110 | | -uuid |
111 | | -.split("-") |
112 | | -.every((part) => part.length > 0 && [...part].every((char) => /[0-9a-f]/.test(char))), |
| 110 | +uuid.split("-").every((part) => /^[0-9a-f]+$/.test(part)), |
113 | 111 | label, |
114 | 112 | ).toBe(true); |
115 | 113 | return value; |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。