test: guard qa lab web mock calls · openclaw/openclaw@8b5cb16
steipete
·
2026-05-12
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -86,6 +86,18 @@ beforeEach(async () => {
|
86 | 86 | vi.clearAllMocks(); |
87 | 87 | }); |
88 | 88 | |
| 89 | +function requireLaunchOptions() { |
| 90 | +const [call] = launch.mock.calls; |
| 91 | +if (!call) { |
| 92 | +throw new Error("expected browser launch call"); |
| 93 | +} |
| 94 | +const [launchOptions] = call; |
| 95 | +if (!launchOptions || typeof launchOptions !== "object" || Array.isArray(launchOptions)) { |
| 96 | +throw new Error("expected browser launch options"); |
| 97 | +} |
| 98 | +return launchOptions as Record<string, unknown>; |
| 99 | +} |
| 100 | + |
89 | 101 | describe("qa web runtime", () => { |
90 | 102 | it("opens, interacts with, snapshots, and closes a page", async () => { |
91 | 103 | const opened = await qaWebOpenPage({ url: "http://127.0.0.1:3000/chat" }); |
@@ -102,7 +114,7 @@ describe("qa web runtime", () => {
|
102 | 114 | const evaluated = await qaWebEvaluate({ pageId: opened.pageId, expression: "'ok'" }); |
103 | 115 | await closeAllQaWebSessions(); |
104 | 116 | |
105 | | -const [launchOptions] = launch.mock.calls[0] ?? []; |
| 117 | +const launchOptions = requireLaunchOptions(); |
106 | 118 | expect(launchOptions?.channel).toBe("chrome"); |
107 | 119 | expect(launchOptions?.headless).toBe(true); |
108 | 120 | expect(goto).toHaveBeenCalledWith("http://127.0.0.1:3000/chat", { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。