test: tighten UI view assertions · openclaw/openclaw@9c5a150
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -59,9 +59,8 @@ describe("OpenClawApp Talk controls", () => {
|
59 | 59 | expect(startMock).toHaveBeenCalledOnce(); |
60 | 60 | expect(stopMock).not.toHaveBeenCalled(); |
61 | 61 | expect(app.realtimeTalkStatus).toBe("connecting"); |
62 | | -expect(app.realtimeTalkSession).toMatchObject({ |
63 | | -start: startMock, |
64 | | -stop: stopMock, |
65 | | -}); |
| 62 | +const session = app.realtimeTalkSession as { start?: unknown; stop?: unknown } | undefined; |
| 63 | +expect(session?.start).toBe(startMock); |
| 64 | +expect(session?.stop).toBe(stopMock); |
66 | 65 | }); |
67 | 66 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -41,14 +41,13 @@ describe("RealtimeTalkSession consult handoff", () => {
|
41 | 41 | submit, |
42 | 42 | }); |
43 | 43 | |
44 | | -expect(request).toHaveBeenCalledWith( |
45 | | -"talk.client.toolCall", |
46 | | -expect.objectContaining({ |
47 | | -sessionKey: "agent:main:main", |
48 | | -name: "openclaw_agent_consult", |
49 | | -args: { question: "Are the basement lights off?" }, |
50 | | -}), |
51 | | -); |
| 44 | +const toolCall = request.mock.calls[0] as |
| 45 | +| [string, { sessionKey?: string; name?: string; args?: { question?: string } }] |
| 46 | +| undefined; |
| 47 | +expect(toolCall?.[0]).toBe("talk.client.toolCall"); |
| 48 | +expect(toolCall?.[1]?.sessionKey).toBe("agent:main:main"); |
| 49 | +expect(toolCall?.[1]?.name).toBe("openclaw_agent_consult"); |
| 50 | +expect(toolCall?.[1]?.args).toEqual({ question: "Are the basement lights off?" }); |
52 | 51 | expect(submit).toHaveBeenCalledWith("call-1", { result: "Basement lights are off." }); |
53 | 52 | }); |
54 | 53 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -740,13 +740,13 @@ describe("chat attachment picker", () => {
|
740 | 740 | input!.dispatchEvent(new Event("change", { bubbles: true })); |
741 | 741 | |
742 | 742 | await vi.waitFor(() => { |
743 | | -expect(onAttachmentsChange).toHaveBeenCalledWith([ |
744 | | -expect.objectContaining({ |
745 | | - fileName: "brief.pdf", |
746 | | - mimeType: "application/pdf", |
747 | | - sizeBytes: file.size, |
748 | | - }), |
749 | | -]); |
| 743 | +const attachments = onAttachmentsChange.mock.calls[0]?.[0] as |
| 744 | +| Array<{ fileName?: string; mimeType?: string; sizeBytes?: number }> |
| 745 | +| undefined; |
| 746 | +expect(attachments).toHaveLength(1); |
| 747 | +expect(attachments?.[0]?.fileName).toBe("brief.pdf"); |
| 748 | +expect(attachments?.[0]?.mimeType).toBe("application/pdf"); |
| 749 | +expect(attachments?.[0]?.sizeBytes).toBe(file.size); |
750 | 750 | }); |
751 | 751 | |
752 | 752 | const nextAttachments = onAttachmentsChange.mock.calls[0]?.[0] ?? []; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -746,20 +746,19 @@ describe("cron view", () => {
|
746 | 746 | "cron-delivery-to-suggestions", |
747 | 747 | "cron-delivery-account-suggestions", |
748 | 748 | ]); |
749 | | -expect( |
750 | | -Array.from(container.querySelectorAll("input[list]")).map((node) => |
751 | | -node.getAttribute("list"), |
752 | | -), |
753 | | -).toEqual( |
754 | | -expect.arrayContaining([ |
755 | | -"cron-agent-suggestions", |
756 | | -"cron-model-suggestions", |
757 | | -"cron-thinking-suggestions", |
758 | | -"cron-tz-suggestions", |
759 | | -"cron-delivery-to-suggestions", |
760 | | -"cron-delivery-account-suggestions", |
761 | | -]), |
| 749 | +const inputLists = Array.from(container.querySelectorAll("input[list]")).map((node) => |
| 750 | +node.getAttribute("list"), |
762 | 751 | ); |
| 752 | +for (const expectedList of [ |
| 753 | +"cron-agent-suggestions", |
| 754 | +"cron-model-suggestions", |
| 755 | +"cron-thinking-suggestions", |
| 756 | +"cron-tz-suggestions", |
| 757 | +"cron-delivery-to-suggestions", |
| 758 | +"cron-delivery-account-suggestions", |
| 759 | +]) { |
| 760 | +expect(inputLists).toContain(expectedList); |
| 761 | +} |
763 | 762 | expect(container.querySelectorAll("input[list]")).toHaveLength(6); |
764 | 763 | }); |
765 | 764 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -508,9 +508,11 @@ describe("dreaming view", () => {
|
508 | 508 | const labels = [...container.querySelectorAll(".dreams-diary__day-chip")].map((node) => |
509 | 509 | node.textContent?.replace(/\s+/g, "").trim(), |
510 | 510 | ); |
511 | | -expect(labels.filter((label): label is string => Boolean(label))).toEqual( |
512 | | -expect.arrayContaining([expect.stringMatching(/^\d+\/\d+$/)]), |
513 | | -); |
| 511 | +expect( |
| 512 | +labels |
| 513 | +.filter((label): label is string => Boolean(label)) |
| 514 | +.some((label) => /^\d+\/\d+$/.test(label)), |
| 515 | +).toBe(true); |
514 | 516 | setDreamSubTab("scene"); |
515 | 517 | }); |
516 | 518 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。