mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-10 11:39:50 +08:00
fix: log Editable SVG saves, use local dates in file names, drop unused Electron dialogs
- /api/log-save accepted only drawio, png and svg, so saving as Editable SVG (xmlsvg) got a 400 and was never recorded in Langfuse - The default download name and the template export name used the UTC date, which is the previous day on mornings in East Asia - Remove the Electron openFile/saveFile IPC handlers, their preload bindings and types; nothing in the app calls them
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
// @vitest-environment node
|
||||
import { describe, expect, it, vi } from "vitest"
|
||||
import { POST as logSave } from "@/app/api/log-save/route"
|
||||
|
||||
// A Langfuse client with a trace to attach the save score to
|
||||
const batch = vi.fn(async () => ({}))
|
||||
vi.mock("@/lib/langfuse", () => ({
|
||||
getLangfuseClient: () => ({
|
||||
api: {
|
||||
trace: { list: async () => ({ data: [{ id: "trace-1" }] }) },
|
||||
ingestion: { batch },
|
||||
},
|
||||
}),
|
||||
}))
|
||||
|
||||
function post(body: unknown): Request {
|
||||
return new Request("http://localhost/api/log-save", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
})
|
||||
}
|
||||
|
||||
describe("POST /api/log-save", () => {
|
||||
it.each(["drawio", "png", "svg", "xmlsvg"])(
|
||||
"logs a save in %s format",
|
||||
async (format) => {
|
||||
const res = await logSave(
|
||||
post({ filename: "diagram", format, sessionId: "s1" }),
|
||||
)
|
||||
expect(res.status).toBe(200)
|
||||
expect(await res.json()).toEqual({ success: true, logged: true })
|
||||
},
|
||||
)
|
||||
|
||||
it("rejects an unknown format", async () => {
|
||||
const res = await logSave(
|
||||
post({ filename: "diagram", format: "pdf", sessionId: "s1" }),
|
||||
)
|
||||
expect(res.status).toBe(400)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user