Files
community-rule/tests/unit/publishedRuleAccess.test.ts
adilalloandCursor 1445cb7e1e Keep listed published rules public and guest-claim rules unlisted, with semantic document markup and share chrome that stays clickable.
Guest publishes remain share-by-link but stay out of the catalog and sitemap, and their pages send noindex until claimed. The published-rule view now uses heading and list markup matching Markdown export, and top banners sit below the header so Share is not covered.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 17:42:01 -06:00

37 lines
954 B
TypeScript

import { describe, expect, it } from "vitest";
import {
LISTED_PUBLISHED_RULE_WHERE,
isListedPublishedRule,
} from "../../lib/publishedRuleAccess";
describe("isListedPublishedRule", () => {
it("lists owned rules", () => {
expect(
isListedPublishedRule({ userId: "user-1", claimTokenHash: null }),
).toBe(true);
});
it("lists ownerless rows that are not waiting on a guest claim", () => {
expect(isListedPublishedRule({ userId: null, claimTokenHash: null })).toBe(
true,
);
});
it("keeps guest-claim rows unlisted", () => {
expect(
isListedPublishedRule({
userId: null,
claimTokenHash: "claim-hash",
}),
).toBe(false);
});
});
describe("LISTED_PUBLISHED_RULE_WHERE", () => {
it("matches owned rows or rows with no claim token", () => {
expect(LISTED_PUBLISHED_RULE_WHERE).toEqual({
OR: [{ userId: { not: null } }, { claimTokenHash: null }],
});
});
});