fix(webui): validate inferred file paths before preview (#4935)
This commit is contained in:
@@ -5,6 +5,7 @@ import {
|
||||
createModelConfiguration,
|
||||
deleteSession,
|
||||
fetchFilePreview,
|
||||
fetchFilePreviewAvailability,
|
||||
fetchAutomations,
|
||||
fetchApiService,
|
||||
fetchCliApps,
|
||||
@@ -102,6 +103,32 @@ describe("webui API helpers", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("probes file preview availability without requesting contents", async () => {
|
||||
await expect(
|
||||
fetchFilePreviewAvailability("tok", "websocket:chat-1", "notes/ready.md"),
|
||||
).resolves.toBe(true);
|
||||
|
||||
expect(fetch).toHaveBeenCalledWith(
|
||||
"/api/sessions/websocket%3Achat-1/file-preview?path=notes%2Fready.md&probe=1",
|
||||
expect.objectContaining({
|
||||
headers: { Authorization: "Bearer tok" },
|
||||
credentials: "same-origin",
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it("returns false when a file preview probe is unavailable", async () => {
|
||||
vi.mocked(fetch).mockResolvedValueOnce({
|
||||
ok: true,
|
||||
status: 200,
|
||||
json: async () => ({ available: false }),
|
||||
} as Response);
|
||||
|
||||
await expect(
|
||||
fetchFilePreviewAvailability("tok", "websocket:chat-1", "notes/missing.md"),
|
||||
).resolves.toBe(false);
|
||||
});
|
||||
|
||||
it("percent-encodes websocket keys when fetching session automations", async () => {
|
||||
await fetchSessionAutomations("tok", "websocket:chat-1");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user