aboutsummaryrefslogtreecommitdiffstats
path: root/packages/shared/import-export/importer.test.ts
diff options
context:
space:
mode:
authorMohamed Bassem <me@mbassem.com>2025-11-15 16:47:20 +0000
committerGitHub <noreply@github.com>2025-11-15 16:47:20 +0000
commit0c80f515ec9e20c70b69380031886ccc0e4bc06d (patch)
treea5f1c9a3c063761671ede8935d9913e8f51c3577 /packages/shared/import-export/importer.test.ts
parent4350666961132ffe68afea8686b567f361a58f57 (diff)
downloadkarakeep-0c80f515ec9e20c70b69380031886ccc0e4bc06d.tar.zst
feat: import from mymind (#2138)
* feat: add mymind importer support This commit adds support for importing bookmarks from mymind CSV exports. Changes: - Added mymind to ImportSource type in parsers.ts - Implemented parseMymindBookmarkFile() to parse mymind CSV format - Added mymind case to parseImportFile() switch statement - Added mymind import card to ImportExport UI component - Added English translation for mymind import description - Added comprehensive test for mymind CSV parsing The mymind CSV format includes: - WebPages (URLs with optional notes) - Notes (text content without URLs) - Tags (comma-separated) - Created timestamps (ISO format) Fixes #654 * format * use zod for parsing --------- Co-authored-by: Claude <noreply@anthropic.com>
Diffstat (limited to 'packages/shared/import-export/importer.test.ts')
-rw-r--r--packages/shared/import-export/importer.test.ts79
1 files changed, 79 insertions, 0 deletions
diff --git a/packages/shared/import-export/importer.test.ts b/packages/shared/import-export/importer.test.ts
index 00f892a9..48cd1204 100644
--- a/packages/shared/import-export/importer.test.ts
+++ b/packages/shared/import-export/importer.test.ts
@@ -401,4 +401,83 @@ describe("importBookmarksFromFile", () => {
// updateBookmarkTags should be called 2 times (once fails at list assignment, one fails at tag update)
expect(updateBookmarkTags).toHaveBeenCalledTimes(2);
});
+
+ it("parses mymind CSV export correctly", async () => {
+ const mymindCsv = `id,type,title,url,content,note,tags,created
+1pYm0O0hY4WnmKN,WebPage,mymind,https://access.mymind.com/everything,,,"Wellness,Self-Improvement,Psychology",2024-12-04T23:02:10Z
+1pYm0O0hY5ltduL,WebPage,Movies / TV / Anime,https://fmhy.pages.dev/videopiracyguide,,"Free Media!","Tools,media,Entertainment",2024-12-04T23:02:32Z
+1pYm0O0hY8oFq9C,Note,,,"• Critical Thinking
+• Empathy",,,2024-12-04T23:05:23Z`;
+
+ const mockFile = {
+ text: vi.fn().mockResolvedValue(mymindCsv),
+ } as unknown as File;
+
+ const createdBookmarks: ParsedBookmark[] = [];
+ const createBookmark = vi.fn(async (bookmark: ParsedBookmark) => {
+ createdBookmarks.push(bookmark);
+ return {
+ id: `bookmark-${createdBookmarks.length}`,
+ alreadyExists: false,
+ };
+ });
+
+ const res = await importBookmarksFromFile({
+ file: mockFile,
+ source: "mymind",
+ rootListName: "mymind Import",
+ deps: {
+ createList: vi.fn(
+ async (input: { name: string; icon: string; parentId?: string }) => ({
+ id: `${input.parentId ? input.parentId + "/" : ""}${input.name}`,
+ }),
+ ),
+ createBookmark,
+ addBookmarkToLists: vi.fn(),
+ updateBookmarkTags: vi.fn(),
+ createImportSession: vi.fn(async () => ({ id: "session-1" })),
+ },
+ });
+
+ expect(res.counts).toEqual({
+ successes: 3,
+ failures: 0,
+ alreadyExisted: 0,
+ total: 3,
+ });
+
+ // Verify first bookmark (WebPage with URL)
+ expect(createdBookmarks[0]).toMatchObject({
+ title: "mymind",
+ content: {
+ type: "link",
+ url: "https://access.mymind.com/everything",
+ },
+ tags: ["Wellness", "Self-Improvement", "Psychology"],
+ });
+ expect(createdBookmarks[0].addDate).toBeCloseTo(
+ new Date("2024-12-04T23:02:10Z").getTime() / 1000,
+ );
+
+ // Verify second bookmark (WebPage with note)
+ expect(createdBookmarks[1]).toMatchObject({
+ title: "Movies / TV / Anime",
+ content: {
+ type: "link",
+ url: "https://fmhy.pages.dev/videopiracyguide",
+ },
+ tags: ["Tools", "media", "Entertainment"],
+ notes: "Free Media!",
+ });
+
+ // Verify third bookmark (Note with text content)
+ expect(createdBookmarks[2]).toMatchObject({
+ title: "",
+ content: {
+ type: "text",
+ text: "• Critical Thinking\n• Empathy",
+ },
+ tags: [],
+ });
+ });
});