mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
test(browser): use a real Response in 429 regression
This commit is contained in:
@@ -139,11 +139,12 @@ describe("fetchBrowserJson loopback auth", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("surfaces 429 from HTTP URL as rate-limit error with no-retry hint", async () => {
|
it("surfaces 429 from HTTP URL as rate-limit error with no-retry hint", async () => {
|
||||||
const text = vi.fn(async () => "max concurrent sessions exceeded");
|
const response = new Response("max concurrent sessions exceeded", { status: 429 });
|
||||||
const cancel = vi.fn(async () => {});
|
const text = vi.spyOn(response, "text");
|
||||||
|
const cancel = vi.spyOn(response.body!, "cancel").mockResolvedValue(undefined);
|
||||||
vi.stubGlobal(
|
vi.stubGlobal(
|
||||||
"fetch",
|
"fetch",
|
||||||
vi.fn(async () => ({ ok: false, status: 429, text, body: { cancel } }) as Response),
|
vi.fn(async () => response),
|
||||||
);
|
);
|
||||||
|
|
||||||
const thrown = await fetchBrowserJson<{ ok: boolean }>("http://127.0.0.1:18888/").catch(
|
const thrown = await fetchBrowserJson<{ ok: boolean }>("http://127.0.0.1:18888/").catch(
|
||||||
|
|||||||
Reference in New Issue
Block a user