From 10506173cd5309e7c63d83055243abc67cecad4f Mon Sep 17 00:00:00 2001 From: Mohamed Bassem Date: Sat, 11 Jan 2025 18:09:51 +0000 Subject: feat: Add support for singlefile extension uploads. #172 --- packages/e2e_tests/tests/api/bookmarks.test.ts | 51 ++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'packages/e2e_tests/tests/api/bookmarks.test.ts') diff --git a/packages/e2e_tests/tests/api/bookmarks.test.ts b/packages/e2e_tests/tests/api/bookmarks.test.ts index 7c605aab..df3cefe2 100644 --- a/packages/e2e_tests/tests/api/bookmarks.test.ts +++ b/packages/e2e_tests/tests/api/bookmarks.test.ts @@ -394,4 +394,55 @@ describe("Bookmarks API", () => { expect(finalPage!.bookmarks.length).toBe(1); expect(finalPage!.nextCursor).toBeNull(); }); + + it("should support precrawling via singlefile", async () => { + const file = new File(["HELLO WORLD"], "test.html", { + type: "text/html", + }); + + const formData = new FormData(); + formData.append("url", "https://example.com"); + formData.append("file", file); + + // OpenAPI typescript doesn't support multipart/form-data + // Upload the singlefile archive + const response = await fetch( + `http://localhost:${port}/api/v1/bookmarks/singlefile`, + { + method: "POST", + headers: { + authorization: `Bearer ${apiKey}`, + }, + body: formData, + }, + ); + + if (!response.ok) { + throw new Error(`Failed to upload asset: ${response.statusText}`); + } + + expect(response.status).toBe(201); + + const { id: bookmarkId } = (await response.json()) as { + id: string; + }; + + // Get the created bookmark + const { data: retrievedBookmark, response: getResponse } = await client.GET( + "/bookmarks/{bookmarkId}", + { + params: { + path: { + bookmarkId: bookmarkId, + }, + }, + }, + ); + + expect(getResponse.status).toBe(200); + assert(retrievedBookmark!.content.type === "link"); + expect(retrievedBookmark!.assets.map((a) => a.assetType)).toContain( + "precrawledArchive", + ); + }); }); -- cgit v1.2.3-70-g09d2