mirror of
https://github.com/DayuanJiang/next-ai-draw-io.git
synced 2026-10-04 00:37:48 +08:00
- 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
26 lines
879 B
TypeScript
26 lines
879 B
TypeScript
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")
|
|
})
|
|
})
|