fix(apps): recover stale npm installs
This commit is contained in:
@@ -40,7 +40,8 @@ async function request<T>(
|
||||
credentials: "same-origin",
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new ApiError(res.status, `HTTP ${res.status}`);
|
||||
const text = typeof res.text === "function" ? (await res.text()).trim() : "";
|
||||
throw new ApiError(res.status, text || `HTTP ${res.status}`);
|
||||
}
|
||||
const contentType = res.headers?.get?.("content-type") ?? "";
|
||||
if (contentType && !contentType.toLowerCase().includes("application/json")) {
|
||||
|
||||
@@ -134,6 +134,22 @@ describe("webui API helpers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("surfaces API error response bodies", async () => {
|
||||
vi.stubGlobal(
|
||||
"fetch",
|
||||
vi.fn().mockResolvedValue({
|
||||
ok: false,
|
||||
status: 500,
|
||||
text: async () => "npm error ENOTEMPTY",
|
||||
}),
|
||||
);
|
||||
|
||||
await expect(runCliAppAction("tok", "install", "hyperframes")).rejects.toMatchObject({
|
||||
status: 500,
|
||||
message: "npm error ENOTEMPTY",
|
||||
});
|
||||
});
|
||||
|
||||
it("serializes provider settings updates without returning secrets", async () => {
|
||||
await updateProviderSettings("tok", {
|
||||
provider: "openrouter",
|
||||
|
||||
Reference in New Issue
Block a user