diff --git a/apps/web/modules/entitlements/lib/self-hosted-provider.test.ts b/apps/web/modules/entitlements/lib/self-hosted-provider.test.ts index a637d2fd20..f0bb7cfd13 100644 --- a/apps/web/modules/entitlements/lib/self-hosted-provider.test.ts +++ b/apps/web/modules/entitlements/lib/self-hosted-provider.test.ts @@ -141,4 +141,77 @@ describe("getSelfHostedOrganizationEntitlementsContext", () => { expect(result.features).toContain("ai-smart-tools"); expect(result.features).toContain("ai-data-analysis"); }); + + test("maps unifyFeedback feature to unify-feedback entitlement", async () => { + mockGetOrg.mockResolvedValue({ id: "org1" } as any); + mockGetLicense.mockResolvedValue({ + status: "active", + active: true, + features: { unifyFeedback: true }, + } as any); + + const result = await getSelfHostedOrganizationEntitlementsContext("org1"); + + expect(result.features).toContain("unify-feedback"); + expect(result.features).not.toContain("feedback-record-directories"); + expect(result.features).not.toContain("dashboards"); + }); + + test("maps feedbackRecordDirectories feature to feedback-record-directories entitlement", async () => { + mockGetOrg.mockResolvedValue({ id: "org1" } as any); + mockGetLicense.mockResolvedValue({ + status: "active", + active: true, + features: { feedbackRecordDirectories: true }, + } as any); + + const result = await getSelfHostedOrganizationEntitlementsContext("org1"); + + expect(result.features).toContain("feedback-record-directories"); + expect(result.features).not.toContain("unify-feedback"); + expect(result.features).not.toContain("dashboards"); + }); + + test("maps dashboards feature to dashboards entitlement", async () => { + mockGetOrg.mockResolvedValue({ id: "org1" } as any); + mockGetLicense.mockResolvedValue({ + status: "active", + active: true, + features: { dashboards: true }, + } as any); + + const result = await getSelfHostedOrganizationEntitlementsContext("org1"); + + expect(result.features).toContain("dashboards"); + expect(result.features).not.toContain("unify-feedback"); + expect(result.features).not.toContain("feedback-record-directories"); + }); + + test("maps all three Hub features when all enabled", async () => { + mockGetOrg.mockResolvedValue({ id: "org1" } as any); + mockGetLicense.mockResolvedValue({ + status: "active", + active: true, + features: { unifyFeedback: true, feedbackRecordDirectories: true, dashboards: true }, + } as any); + + const result = await getSelfHostedOrganizationEntitlementsContext("org1"); + + expect(result.features).toContain("unify-feedback"); + expect(result.features).toContain("feedback-record-directories"); + expect(result.features).toContain("dashboards"); + }); + + test("does not map Hub features when license inactive even if flags are true", async () => { + mockGetOrg.mockResolvedValue({ id: "org1" } as any); + mockGetLicense.mockResolvedValue({ + status: "expired", + active: false, + features: { unifyFeedback: true, feedbackRecordDirectories: true, dashboards: true }, + } as any); + + const result = await getSelfHostedOrganizationEntitlementsContext("org1"); + + expect(result.features).toEqual([]); + }); });