mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-13 04:59:51 +08:00
fix(chat-input): stop template dialogs from sending and fix attachment races
- Template dialogs no longer submit the outer chat form - Sending is blocked while files or URLs are still extracting - File and URL extraction no longer drop or resurrect entries - IME composition Enter no longer sends - Tool call cards show the error text; keyboard handling on cards fixed - Template import available when empty, edit dialog resets, saved templates refresh - Only png/jpeg/gif/webp images accepted, SVG sent as text; PDF objects released - parse-url request sends the access code
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest"
|
||||
import { STORAGE_KEYS } from "@/lib/storage"
|
||||
import { extractUrlContent } from "@/lib/url-utils"
|
||||
|
||||
describe("extractUrlContent", () => {
|
||||
afterEach(() => {
|
||||
vi.unstubAllGlobals()
|
||||
localStorage.clear()
|
||||
})
|
||||
|
||||
it("sends the saved access code with the request", async () => {
|
||||
localStorage.setItem(STORAGE_KEYS.accessCode, "secret")
|
||||
const body = { title: "T", content: "body", charCount: 4 }
|
||||
const fetchMock = vi
|
||||
.fn()
|
||||
.mockResolvedValue(new Response(JSON.stringify(body)))
|
||||
vi.stubGlobal("fetch", fetchMock)
|
||||
|
||||
const data = await extractUrlContent("https://example.com")
|
||||
|
||||
expect(data.content).toBe("body")
|
||||
const headers = fetchMock.mock.calls[0][1].headers
|
||||
expect(headers["x-access-code"]).toBe("secret")
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user