Skip to content

Build your personal knowledge base with Trilium Notes

test(client): cover an attachment embed whose attachment cannot load

Elian Doran3e5cc695ae92
diff --git a/apps/client/src/services/content_renderer_text.spec.ts b/apps/client/src/services/content_renderer_text.spec.ts
index a3768e7ff1..6cbbb475d5 100644
--- a/apps/client/src/services/content_renderer_text.spec.ts
+++ b/apps/client/src/services/content_renderer_text.spec.ts
@@ -546,6 +546,22 @@ describe("Attachment embeds", () => {
expect(nestedEl.querySelector("a.reference-link")?.getAttribute("href"))
.toBe(`#root/${owner.noteId}?viewMode=attachments&attachmentId=embedPic`);
});
+
+ it("leaves the embed of an attachment that cannot be loaded as it is", async () => {
+ const owner = buildNote({
+ title: "Missing embed owner",
+ content: `<section class="include-note" data-attachment-id="gonePic">&nbsp;</section>`
+ });
+ const getAttachment = vi.spyOn(froca, "getAttachment").mockResolvedValue(null);
+
+ const contentEl = document.createElement("div");
+ await renderText(owner, $(contentEl));
+
+ expect(getAttachment).toHaveBeenCalledWith("gonePic", true);
+ expect(contentEl.querySelector(`section.include-note[data-attachment-id="gonePic"]`)?.innerHTML)
+ .toBe("&nbsp;");
+ getAttachment.mockRestore();
+ });
});
describe("postProcessRichContent with FAttachment", () => {