Skip to content

Build your personal knowledge base with Trilium Notes

test(import/zip): test silverbullet import

Elian Dorana95dc14d2409
diff --git a/apps/server/src/services/import/samples/silverbullet.zip b/apps/server/src/services/import/samples/silverbullet.zip
new file mode 100644
index 0000000000..f3fa8dfd8d
Binary files /dev/null and b/apps/server/src/services/import/samples/silverbullet.zip differ
diff --git a/apps/server/src/services/import/zip.spec.ts b/apps/server/src/services/import/zip.spec.ts
index 935b13f659..4860f7b94c 100644
--- a/apps/server/src/services/import/zip.spec.ts
+++ b/apps/server/src/services/import/zip.spec.ts
@@ -60,8 +60,29 @@ describe("processNoteContent", () => {
const htmlNote = rootNote.children.find((ch) => ch.title === "IREN Reports Q2 FY25 Results");
expect(htmlNote?.getContent().toString().substring(0, 4)).toEqual("<div");
});
+
+ it("can import from Silverbullet", async () => {
+ const { importedNote } = await testImport("silverbullet.zip");
+ const bananaNote = getNoteByTitlePath(importedNote, "assets", "banana.jpeg");
+ const mondayNote = getNoteByTitlePath(importedNote, "journal", "monday");
+ const shopNote = getNoteByTitlePath(importedNote, "other", "shop");
+ const content = mondayNote?.getContent();
+ expect(content).toContain(`<a class="reference-link" href="#root/${shopNote.noteId}`);
+ expect(content).toContain(`<img src="api/images/${bananaNote!.noteId}/banana.jpeg`);
+ });
});
+function getNoteByTitlePath(parentNote: BNote, ...titlePath: string[]) {
+ let cursor = parentNote;
+ for (const title of titlePath) {
+ const childNote = cursor.getChildNotes().find(n => n.title === title);
+ expect(childNote).toBeTruthy();
+ cursor = childNote!;
+ }
+
+ return cursor;
+}
+
describe("removeTriliumTags", () => {
it("removes <h1> tags from HTML", () => {
const output = removeTriliumTags(trimIndentation`\