Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
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.tsindex 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"> </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(" ");+ getAttachment.mockRestore();+ });});describe("postProcessRichContent with FAttachment", () => {