Files
Tom Moor a40198a97d feat: Add expiry dates for public share links (#14513)
* wip

* fix: Treat null expiresAt as no expiry when creating a share

* fix: Add bottom padding to share notices
2026-11-09 22:29:49 -05:00

38 lines
1.0 KiB
TypeScript

import { addDays, subDays } from "date-fns";
import { Share } from "@server/models";
import { buildShare } from "@server/test/factories";
describe("Share", () => {
describe("getPublicSharesForDocumentIds", () => {
it("should return shares without an expiry or with a future expiry", async () => {
const noExpiry = await buildShare();
const future = await buildShare({
teamId: noExpiry.teamId,
expiresAt: addDays(new Date(), 1),
});
const shares = await Share.getPublicSharesForDocumentIds(
noExpiry.teamId,
[noExpiry.documentId!, future.documentId!]
);
expect(shares.map((share) => share.id).sort()).toEqual(
[noExpiry.id, future.id].sort()
);
});
it("should not return expired shares", async () => {
const share = await buildShare({
expiresAt: subDays(new Date(), 1),
});
const shares = await Share.getPublicSharesForDocumentIds(
share.teamId,
share.documentId!
);
expect(shares).toEqual([]);
});
});
});