test: tighten remaining UI assertions · openclaw/openclaw@2c89dad
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -841,12 +841,13 @@ describe("connectGateway", () => {
|
841 | 841 | }, |
842 | 842 | }); |
843 | 843 | |
844 | | -expect(host.chatSideResult).toMatchObject({ |
845 | | -kind: "btw", |
846 | | -runId: "btw-run-1", |
847 | | -question: "what changed?", |
848 | | -text: "Only the UI layer is missing support.", |
849 | | -}); |
| 844 | +const sideResult = host.chatSideResult as |
| 845 | +| { kind?: string; runId?: string; question?: string; text?: string } |
| 846 | +| undefined; |
| 847 | +expect(sideResult?.kind).toBe("btw"); |
| 848 | +expect(sideResult?.runId).toBe("btw-run-1"); |
| 849 | +expect(sideResult?.question).toBe("what changed?"); |
| 850 | +expect(sideResult?.text).toBe("Only the UI layer is missing support."); |
850 | 851 | expect(host.chatSideResultTerminalRuns.has("btw-run-1")).toBe(true); |
851 | 852 | }); |
852 | 853 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -260,10 +260,11 @@ describe("renderApp assistant avatar routing", () => {
|
260 | 260 | quickSettingsProps.current?.onToolProfileChange?.("full"); |
261 | 261 | |
262 | 262 | expect(state.configForm?.browser).toEqual({ enabled: true }); |
263 | | -expect(state.configForm?.tools).toMatchObject({ |
264 | | -profile: "full", |
265 | | -exec: { security: "full" }, |
266 | | -}); |
| 263 | +const tools = state.configForm?.tools as |
| 264 | +| { profile?: string; exec?: { security?: string } } |
| 265 | +| undefined; |
| 266 | +expect(tools?.profile).toBe("full"); |
| 267 | +expect(tools?.exec?.security).toBe("full"); |
267 | 268 | }); |
268 | 269 | |
269 | 270 | it("renders stale cron state containing a job without a payload", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -251,12 +251,13 @@ describe("context notice", () => {
|
251 | 251 | contextTokens: 200_000, |
252 | 252 | }; |
253 | 253 | const lowUsage = getContextNoticeViewModel(lowUsageSession, 200_000); |
254 | | -expect(lowUsage).toMatchObject({ |
255 | | -pct: 23, |
256 | | -detail: "46k / 200k", |
257 | | -warning: false, |
258 | | -compactRecommended: false, |
259 | | -}); |
| 254 | +if (!lowUsage) { |
| 255 | +throw new Error("expected low usage context notice"); |
| 256 | +} |
| 257 | +expect(lowUsage.pct).toBe(23); |
| 258 | +expect(lowUsage.detail).toBe("46k / 200k"); |
| 259 | +expect(lowUsage.warning).toBe(false); |
| 260 | +expect(lowUsage.compactRecommended).toBe(false); |
260 | 261 | render(renderContextNotice(lowUsageSession, 200_000), container); |
261 | 262 | expect(container.textContent).toContain("23% context used"); |
262 | 263 | expect(container.textContent).toContain("46k / 200k"); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -9,10 +9,9 @@ describe("slash command browser import", () => {
|
9 | 9 | it("builds fallback commands from the browser-safe shared registry", async () => { |
10 | 10 | const mod = (await import(browserImportPath)) as SlashCommandsModule; |
11 | 11 | |
12 | | -expect(mod.SLASH_COMMANDS.find((command) => command.name === "think")).toMatchObject({ |
13 | | -name: "think", |
14 | | -category: "model", |
15 | | -}); |
| 12 | +const thinkCommand = mod.SLASH_COMMANDS.find((command) => command.name === "think"); |
| 13 | +expect(thinkCommand?.name).toBe("think"); |
| 14 | +expect(thinkCommand?.category).toBe("model"); |
16 | 15 | }); |
17 | 16 | |
18 | 17 | it("keeps provider thinking runtime out of the Control UI import path", async () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -178,12 +178,11 @@ describe("tool-cards", () => {
|
178 | 178 | expect(sidebarButton?.classList.contains("chat-tool-card__action-btn")).toBe(true); |
179 | 179 | sidebarButton!.click(); |
180 | 180 | |
181 | | -expect(onOpenSidebar).toHaveBeenCalledWith( |
182 | | -expect.objectContaining({ |
183 | | -kind: "canvas", |
184 | | -docId: "cv_sidebar", |
185 | | -entryUrl: "/__openclaw__/canvas/documents/cv_sidebar/index.html", |
186 | | -}), |
187 | | -); |
| 181 | +const sidebar = onOpenSidebar.mock.calls[0]?.[0] as |
| 182 | +| { kind?: string; docId?: string; entryUrl?: string } |
| 183 | +| undefined; |
| 184 | +expect(sidebar?.kind).toBe("canvas"); |
| 185 | +expect(sidebar?.docId).toBe("cv_sidebar"); |
| 186 | +expect(sidebar?.entryUrl).toBe("/__openclaw__/canvas/documents/cv_sidebar/index.html"); |
188 | 187 | }); |
189 | 188 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -371,11 +371,8 @@ describe("saveAgentsConfig", () => {
|
371 | 371 | |
372 | 372 | await saveAgentsConfig(state); |
373 | 373 | |
374 | | -expect(request).toHaveBeenNthCalledWith( |
375 | | -1, |
376 | | -"config.set", |
377 | | -expect.objectContaining({ baseHash: "hash-1" }), |
378 | | -); |
| 374 | +expect(request.mock.calls[0]?.[0]).toBe("config.set"); |
| 375 | +expect(request.mock.calls[0]?.[1]?.baseHash).toBe("hash-1"); |
379 | 376 | expect(JSON.parse(request.mock.calls[0]?.[1]?.raw as string)).toEqual({ |
380 | 377 | agents: { list: [{ id: "main" }] }, |
381 | 378 | }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -324,12 +324,10 @@ describe("control UI routing", () => {
|
324 | 324 | await nextFrame(); |
325 | 325 | await app.updateComplete; |
326 | 326 | |
327 | | -expect(request).toHaveBeenCalledWith( |
328 | | -"config.patch", |
329 | | -expect.objectContaining({ |
330 | | -baseHash: "hash-1", |
331 | | -}), |
332 | | -); |
| 327 | +const patchCall = request.mock.calls.find((call) => call[0] === "config.patch") as |
| 328 | +| [string, { baseHash?: string }] |
| 329 | +| undefined; |
| 330 | +expect(patchCall?.[1].baseHash).toBe("hash-1"); |
333 | 331 | }); |
334 | 332 | |
335 | 333 | it("renders the refreshed top navigation shell", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。