test: tighten qa credential fetch assertion · openclaw/openclaw@2187f98
shakkernerd
·
2026-05-09
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -16,6 +16,15 @@ function jsonResponse(payload: unknown, status = 200) {
|
16 | 16 | }); |
17 | 17 | } |
18 | 18 | |
| 19 | +function requireFirstFetchInput(fetchImpl: ReturnType<typeof vi.fn>): RequestInfo | URL { |
| 20 | +const input = fetchImpl.mock.calls[0]?.[0] as RequestInfo | URL | undefined; |
| 21 | +expect(input).toBeDefined(); |
| 22 | +if (!input) { |
| 23 | +throw new Error("expected fetch input"); |
| 24 | +} |
| 25 | +return input; |
| 26 | +} |
| 27 | + |
19 | 28 | describe("qa credential admin runtime", () => { |
20 | 29 | it("adds a credential set through the admin endpoint", async () => { |
21 | 30 | const fetchImpl = vi.fn(async (_input: RequestInfo | URL, _init?: RequestInit) => |
@@ -112,7 +121,9 @@ describe("qa credential admin runtime", () => {
|
112 | 121 | fetchImpl, |
113 | 122 | }); |
114 | 123 | |
115 | | -expect(fetchImpl.mock.calls[0]?.[0]).toBe("http://127.0.0.1:3210/qa-credentials/v1/admin/list"); |
| 124 | +expect(requireFirstFetchInput(fetchImpl)).toBe( |
| 125 | +"http://127.0.0.1:3210/qa-credentials/v1/admin/list", |
| 126 | +); |
116 | 127 | }); |
117 | 128 | |
118 | 129 | it("rejects unsafe endpoint-prefix overrides", async () => { |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。