File
Blob: tests/shared/entitlements-site-publishing.test.ts
| 1 | import { describe, expect, it } from "vitest"; |
| 2 | |
| 3 | import { getSitePublishingEntitlements } from "@/shared/entitlements"; |
| 4 | |
| 5 | describe("getSitePublishingEntitlements", () => { |
| 6 | it("grants every capability to owners and admins", () => { |
| 7 | for (const role of ["owner", "admin"] as const) { |
| 8 | const ents = getSitePublishingEntitlements(role); |
| 9 | expect(ents).toEqual({ |
| 10 | manageSite: true, |
| 11 | viewPagePublishStatus: true, |
| 12 | }); |
| 13 | } |
| 14 | }); |
| 15 | |
| 16 | it("gives members read-only publish status only", () => { |
| 17 | const ents = getSitePublishingEntitlements("member"); |
| 18 | expect(ents.viewPagePublishStatus).toBe(true); |
| 19 | expect(ents.manageSite).toBe(false); |
| 20 | }); |
| 21 | |
| 22 | it("denies guests and non-members across the board", () => { |
| 23 | for (const role of ["guest", "none"] as const) { |
| 24 | const ents = getSitePublishingEntitlements(role); |
| 25 | expect(Object.values(ents).some(Boolean)).toBe(false); |
| 26 | } |
| 27 | }); |
| 28 | }); |