diff --git a/server/routes/api/documents/documents.test.ts b/server/routes/api/documents/documents.test.ts index bde267871..166c74d2a 100644 --- a/server/routes/api/documents/documents.test.ts +++ b/server/routes/api/documents/documents.test.ts @@ -552,113 +552,6 @@ describe("#documents.export", () => { expect(body.data).toEqual(DocumentHelper.toMarkdown(document)); }); - it("should return document from shareId without token", async () => { - const { document, user } = await seed(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - const res = await server.post("/api/documents.export", { - body: { - shareId: share.id, - }, - }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data).toEqual(DocumentHelper.toMarkdown(document)); - }); - - it("should not return document from revoked shareId", async () => { - const { document, user } = await seed(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - await share.revoke(user.id); - const res = await server.post("/api/documents.export", { - body: { - shareId: share.id, - }, - }); - expect(res.status).toEqual(400); - }); - - it("should not return document from archived shareId", async () => { - const { document, user } = await seed(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - await document.archive(user.id); - const res = await server.post("/api/documents.export", { - body: { - shareId: share.id, - }, - }); - expect(res.status).toEqual(400); - }); - - it("should return document from shareId with token", async () => { - const { user, document } = await seed(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - const res = await server.post("/api/documents.export", { - body: { - token: user.getJwtToken(), - shareId: share.id, - }, - }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data).toEqual(DocumentHelper.toMarkdown(document)); - }); - - it("should return draft document from shareId with token", async () => { - const { user, document } = await seed(); - document.publishedAt = null; - await document.save(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - const res = await server.post("/api/documents.export", { - body: { - token: user.getJwtToken(), - shareId: share.id, - }, - }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data).toEqual(DocumentHelper.toMarkdown(document)); - }); - - it("should return document from shareId in collection not a member of", async () => { - const { user, document, collection } = await seed(); - const share = await buildShare({ - documentId: document.id, - teamId: document.teamId, - userId: user.id, - }); - collection.permission = null; - await collection.save(); - const res = await server.post("/api/documents.export", { - body: { - token: user.getJwtToken(), - shareId: share.id, - }, - }); - const body = await res.json(); - expect(res.status).toEqual(200); - expect(body.data).toEqual(DocumentHelper.toMarkdown(document)); - }); - it("should require authorization without token", async () => { const { document } = await seed(); const res = await server.post("/api/documents.export", { @@ -680,15 +573,6 @@ describe("#documents.export", () => { }); expect(res.status).toEqual(403); }); - - it("should require a valid shareId", async () => { - const res = await server.post("/api/documents.export", { - body: { - shareId: 123, - }, - }); - expect(res.status).toEqual(400); - }); }); describe("#documents.list", () => { @@ -1163,20 +1047,6 @@ describe("#documents.search_titles", () => { }); describe("#documents.search", () => { - it("should fail for invalid shareId", async () => { - const { user } = await seed(); - const res = await server.post("/api/documents.search", { - body: { - token: user.getJwtToken(), - query: "much", - shareId: "invalid", - }, - }); - const body = await res.json(); - expect(res.status).toEqual(400); - expect(body.message).toEqual("shareId: Invalid uuid"); - }); - it("should return results", async () => { const { user } = await seed(); const res = await server.post("/api/documents.search", {