test: tighten small onboarding model assertions · openclaw/openclaw@fd52454
steipete
·
2026-05-10
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -150,18 +150,16 @@ describe("agent session resolution", () => {
|
150 | 150 | const resolution = resolveSession({ cfg, sessionId }); |
151 | 151 | expect(resolution.sessionKey).toBe(sessionKey); |
152 | 152 | const agentId = resolveSessionAgentId({ sessionKey: resolution.sessionKey, config: cfg }); |
153 | | -expect( |
154 | | -buildOutboundSessionContext({ |
155 | | - cfg, |
156 | | -sessionKey: resolution.sessionKey, |
157 | | - agentId, |
158 | | -}), |
159 | | -).toEqual( |
160 | | -expect.objectContaining({ |
161 | | -key: sessionKey, |
162 | | -agentId: "exec", |
163 | | -}), |
164 | | -); |
| 153 | +const outboundContext = buildOutboundSessionContext({ |
| 154 | + cfg, |
| 155 | +sessionKey: resolution.sessionKey, |
| 156 | + agentId, |
| 157 | +}); |
| 158 | +if (!outboundContext) { |
| 159 | +throw new Error("expected outbound session context"); |
| 160 | +} |
| 161 | +expect(outboundContext.key).toBe(sessionKey); |
| 162 | +expect(outboundContext.agentId).toBe("exec"); |
165 | 163 | }); |
166 | 164 | }); |
167 | 165 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -165,7 +165,9 @@ describe("resolveChannelSetupEntries workspace shadow exclusion (GHSA-2qrv-rc5x-
|
165 | 165 | const fallbackCall = listChannelPluginCatalogEntries.mock.calls.find( |
166 | 166 | ([opts]) => (opts as { excludeWorkspace?: boolean } | undefined)?.excludeWorkspace === true, |
167 | 167 | ); |
168 | | -expect(fallbackCall?.[0]).toMatchObject({ excludeWorkspace: true }); |
| 168 | +expect( |
| 169 | +(fallbackCall?.[0] as { excludeWorkspace?: boolean } | undefined)?.excludeWorkspace, |
| 170 | +).toBe(true); |
169 | 171 | }); |
170 | 172 | |
171 | 173 | it("still returns bundled-origin entries", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -15,11 +15,11 @@ describe("loadProviderIndexCatalogRowsForList", () => {
|
15 | 15 | }); |
16 | 16 | |
17 | 17 | it("returns all enabled provider-index preview rows without a provider filter", () => { |
18 | | -expect( |
19 | | -loadProviderIndexCatalogRowsForList({ |
20 | | - cfg: baseConfig, |
21 | | - }).map((row) => row.ref), |
22 | | -).toEqual(expect.arrayContaining(["deepseek/deepseek-chat", "moonshot/kimi-k2.6"])); |
| 18 | +const refs = loadProviderIndexCatalogRowsForList({ |
| 19 | +cfg: baseConfig, |
| 20 | +}).map((row) => row.ref); |
| 21 | +expect(refs).toContain("deepseek/deepseek-chat"); |
| 22 | +expect(refs).toContain("moonshot/kimi-k2.6"); |
23 | 23 | }); |
24 | 24 | |
25 | 25 | it("suppresses provider-index preview rows when the provider plugin is disabled", () => { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -190,10 +190,8 @@ describe("resolveNonInteractiveApiKey", () => {
|
190 | 190 | }); |
191 | 191 | |
192 | 192 | expect(result).toEqual({ key: "custom-profile-key", source: "profile" }); |
193 | | -expect(resolveApiKeyForProfile).toHaveBeenCalledWith( |
194 | | -expect.objectContaining({ |
195 | | -profileId: "custom-models-custom-local:default", |
196 | | -}), |
197 | | -); |
| 193 | +expect(resolveApiKeyForProfile).toHaveBeenCalledOnce(); |
| 194 | +const [profileParams] = resolveApiKeyForProfile.mock.calls[0] ?? []; |
| 195 | +expect(profileParams?.profileId).toBe("custom-models-custom-local:default"); |
198 | 196 | }); |
199 | 197 | }); |
| Original file line number | Diff line number | Diff line change |
|---|
@@ -186,7 +186,10 @@ describe("applyNonInteractiveGatewayConfig token resolution chain", () => {
|
186 | 186 | }); |
187 | 187 | |
188 | 188 | const newToken = result?.nextConfig.gateway?.auth?.token; |
189 | | -expect(newToken).toMatchObject({ source: "env", id: newRefId }); |
| 189 | +expect(typeof newToken).toBe("object"); |
| 190 | +const newTokenRef = typeof newToken === "object" && newToken !== null ? newToken : undefined; |
| 191 | +expect(newTokenRef?.source).toBe("env"); |
| 192 | +expect(newTokenRef?.id).toBe(newRefId); |
190 | 193 | expect(newToken).not.toEqual(SAMPLE_SECRET_REF); |
191 | 194 | expect(randomToken).not.toHaveBeenCalled(); |
192 | 195 | } finally { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。