test: tighten channel assertion checks · openclaw/openclaw@9074f08
steipete
·
2026-05-11
·
via Recent Commits to openclaw:main
File tree
extensions/browser/src/cli
| Original file line number | Diff line number | Diff line change |
|---|
@@ -38,7 +38,8 @@ vi.spyOn(cliCoreApiModule.defaultRuntime, "exit").mockImplementation(browserCliR
|
38 | 38 | const { registerBrowserStateCommands } = await import("./browser-cli-state.js"); |
39 | 39 | |
40 | 40 | describe("browser state option collisions", () => { |
41 | | -const stripAnsi = (value: string) => value.replace(/\u001b\[[0-9;]*m/g, ""); |
| 41 | +const ansiPattern = new RegExp(String.raw`\u001b\[[0-9;]*m`, "g"); |
| 42 | +const stripAnsi = (value: string) => value.replace(ansiPattern, ""); |
42 | 43 | |
43 | 44 | const createStateProgram = ({ withGatewayUrl = false } = {}) => { |
44 | 45 | const { program, browser, parentOpts } = createBrowserProgramShared({ withGatewayUrl }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -222,13 +222,11 @@ describe("bundled channel entry shape guards", () => {
|
222 | 222 | ); |
223 | 223 | |
224 | 224 | const plugin = bundled.requireBundledChannelPlugin("alpha"); |
225 | | -expect(plugin.meta).toMatchObject({ |
226 | | -id: "alpha", |
227 | | -label: "Alpha", |
228 | | -selectionLabel: "Use Alpha", |
229 | | -docsPath: "/channels/alpha", |
230 | | -blurb: "Alpha channel metadata.", |
231 | | -}); |
| 225 | +expect(plugin.meta.id).toBe("alpha"); |
| 226 | +expect(plugin.meta.label).toBe("Alpha"); |
| 227 | +expect(plugin.meta.selectionLabel).toBe("Use Alpha"); |
| 228 | +expect(plugin.meta.docsPath).toBe("/channels/alpha"); |
| 229 | +expect(plugin.meta.blurb).toBe("Alpha channel metadata."); |
232 | 230 | } finally { |
233 | 231 | restoreBundledPluginsDir(previousBundledPluginsDir); |
234 | 232 | fs.rmSync(tempRoot, { recursive: true, force: true }); |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -5,9 +5,10 @@ const discordSessionBindingAdapterChannels = ["discord"] as const;
|
5 | 5 | |
6 | 6 | describe("channel contract registry", () => { |
7 | 7 | function expectSessionBindingCoverage(expectedChannelIds: readonly string[]) { |
8 | | -expect([...sessionBindingContractChannelIds]).toEqual( |
9 | | -expect.arrayContaining([...expectedChannelIds]), |
10 | | -); |
| 8 | +const registeredIds = new Set<string>(sessionBindingContractChannelIds); |
| 9 | +for (const expectedChannelId of expectedChannelIds) { |
| 10 | +expect(registeredIds.has(expectedChannelId)).toBe(true); |
| 11 | +} |
11 | 12 | } |
12 | 13 | |
13 | 14 | it.each([ |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -141,20 +141,15 @@ describe("session conversation bundled fallback", () => {
|
141 | 141 | it("delegates repeated fallback calls through the public-surface loader", () => { |
142 | 142 | enableThreadedFallback(); |
143 | 143 | |
144 | | -expect(resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:42")).toEqual( |
145 | | -expect.objectContaining({ |
146 | | -channel: "mock-threaded", |
147 | | -id: "room", |
148 | | -threadId: "42", |
149 | | -}), |
150 | | -); |
151 | | -expect(resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:43")).toEqual( |
152 | | -expect.objectContaining({ |
153 | | -channel: "mock-threaded", |
154 | | -id: "room", |
155 | | -threadId: "43", |
156 | | -}), |
157 | | -); |
| 144 | +const firstRef = resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:42"); |
| 145 | +expect(firstRef?.channel).toBe("mock-threaded"); |
| 146 | +expect(firstRef?.id).toBe("room"); |
| 147 | +expect(firstRef?.threadId).toBe("42"); |
| 148 | + |
| 149 | +const secondRef = resolveSessionConversationRef("agent:main:mock-threaded:group:room:topic:43"); |
| 150 | +expect(secondRef?.channel).toBe("mock-threaded"); |
| 151 | +expect(secondRef?.id).toBe("room"); |
| 152 | +expect(secondRef?.threadId).toBe("43"); |
158 | 153 | expect(fallbackState.loadCalls).toBe(2); |
159 | 154 | }); |
160 | 155 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -2118,12 +2118,14 @@ describe("resolveAccountIdForConfigure", () => {
|
2118 | 2118 | }); |
2119 | 2119 | |
2120 | 2120 | expect(accountId).toBe("prompted-id"); |
2121 | | -expect(prompter.select).toHaveBeenCalledWith( |
2122 | | -expect.objectContaining({ |
2123 | | -message: "Signal account", |
2124 | | -initialValue: "fallback", |
2125 | | -}), |
2126 | | -); |
| 2121 | +const selectCalls = prompter.select.mock.calls as unknown as Array< |
| 2122 | +[{ message?: string; initialValue?: string }] |
| 2123 | +>; |
| 2124 | +const selectOptions = selectCalls[0]?.[0] as |
| 2125 | +| { message?: string; initialValue?: string } |
| 2126 | +| undefined; |
| 2127 | +expect(selectOptions?.message).toBe("Signal account"); |
| 2128 | +expect(selectOptions?.initialValue).toBe("fallback"); |
2127 | 2129 | expect(prompter.text).not.toHaveBeenCalled(); |
2128 | 2130 | }); |
2129 | 2131 | }); |
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。