Files
next-ai-draw-io/tests/unit/url-utils.test.ts
T
dayuan.jiang 87edf2e19d 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
2026-10-03 17:45:41 +09:00

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")
})
})