diff --git a/server/app.test.js b/server/app.test.js index 8c4b20d6..526061c1 100644 --- a/server/app.test.js +++ b/server/app.test.js @@ -28,6 +28,19 @@ describe("/share/:id", () => { expect(body).toContain("Outline"); }); + it("should return standard title in html when document is deleted", async () => { + const document = await buildDocument(); + const share = await buildShare({ documentId: document.id }); + + await document.destroy(); + + const res = await server.get(`/share/${share.id}`); + const body = await res.text(); + + expect(res.status).toEqual(200); + expect(body).toContain("Outline"); + }); + it("should return document title in html when loading published share", async () => { const document = await buildDocument(); const share = await buildShare({ documentId: document.id }); diff --git a/server/routes.js b/server/routes.js index ee9e8958..850d56a3 100644 --- a/server/routes.js +++ b/server/routes.js @@ -82,7 +82,7 @@ const renderShare = async (ctx, next) => { // Allow shares to be embedded in iframes on other websites ctx.remove("X-Frame-Options"); - return renderApp(ctx, next, share ? share.document.title : undefined); + return renderApp(ctx, next, share?.document?.title); }; // serve static assets