test: consolidate repetitive cases across the suite
This commit is contained in:
1 parent
c406024b59
commit
6eccc2859a
31 files changed
+745
-1315
No files matched your search
@@ -2787,44 +2787,25 @@ describe("useNanobotStream", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("keeps assistant html media as a file attachment", () => {
|
||||
it.each([
|
||||
{ name: "index.html", kind: "file", url: "/api/media/sig/html" },
|
||||
{ name: "growth.svg", kind: "image", url: "/api/media/sig/svg" },
|
||||
])("classifies assistant $name media as $kind", ({ name, kind, url }) => {
|
||||
const fake = fakeClient();
|
||||
const { result } = renderHook(() => useNanobotStream("chat-html-media", EMPTY_MESSAGES), {
|
||||
const { result } = renderHook(() => useNanobotStream("chat-media", EMPTY_MESSAGES), {
|
||||
wrapper: wrap(fake.client),
|
||||
});
|
||||
|
||||
act(() => {
|
||||
fake.emit("chat-html-media", {
|
||||
fake.emit("chat-media", {
|
||||
event: "message",
|
||||
chat_id: "chat-html-media",
|
||||
text: "file ready",
|
||||
media_urls: [{ url: "/api/media/sig/html", name: "index.html" }],
|
||||
chat_id: "chat-media",
|
||||
text: "media ready",
|
||||
media_urls: [{ url, name }],
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.messages[0].media).toEqual([
|
||||
{ kind: "file", url: "/api/media/sig/html", name: "index.html" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("infers assistant svg media as an image attachment", () => {
|
||||
const fake = fakeClient();
|
||||
const { result } = renderHook(() => useNanobotStream("chat-svg-media", EMPTY_MESSAGES), {
|
||||
wrapper: wrap(fake.client),
|
||||
});
|
||||
|
||||
act(() => {
|
||||
fake.emit("chat-svg-media", {
|
||||
event: "message",
|
||||
chat_id: "chat-svg-media",
|
||||
text: "chart ready",
|
||||
media_urls: [{ url: "/api/media/sig/svg", name: "growth.svg" }],
|
||||
});
|
||||
});
|
||||
|
||||
expect(result.current.messages[0].media).toEqual([
|
||||
{ kind: "image", url: "/api/media/sig/svg", name: "growth.svg" },
|
||||
]);
|
||||
expect(result.current.messages[0].media).toEqual([{ kind, url, name }]);
|
||||
});
|
||||
|
||||
it("corrects explicit image media when the name is a non-image file", () => {
|
||||
|
||||
Reference in new issue
Block a user