From 41c81be07a511d99aec85affcca52481e1f28ccf Mon Sep 17 00:00:00 2001 From: Apoorv Mishra Date: Sat, 16 Sep 2023 11:04:30 +0530 Subject: [PATCH] fix: test for individually shared draft --- server/routes/api/documents/documents.test.ts | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index 4f668ac70d..1506cb2459 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -1775,6 +1775,45 @@ describe("#documents.search", () => { expect(body.data[0].document.id).toEqual(document.id); expect(res.status).toEqual(200); }); + + it("should include individually shared drafts with a user in search results", async () => { + const user = await buildUser(); + // create a collection + const collection = await buildCollection({ + createdById: user.id, + teamId: user.teamId, + }); + // create a draft in collection + const document = await buildDocument({ + collectionId: collection.id, + teamId: user.teamId, + createdById: user.id, + title: "Some title", + }); + document.publishedAt = null; + await document.save(); + const member = await buildUser({ + teamId: user.teamId, + }); + // add member to the document + await server.post("/api/documents.add_user", { + body: { + token: user.getJwtToken(), + id: document.id, + userId: member.id, + }, + }); + const res = await server.post("/api/documents.search", { + body: { + token: member.getJwtToken(), + query: "title", + }, + }); + const body = await res.json(); + expect(body.data).toHaveLength(1); + expect(body.data[0].document.id).toEqual(document.id); + expect(res.status).toEqual(200); + }); }); describe("#documents.templatize", () => {