MotirBuilding in public
MOTIR · moooon
onMotir
You’re viewing a public project. Anyone can view it — no account needed. Sign in to submit, upvote, or comment on requests.View-only — you can’t edit work items
MOTIR-428

6.13.7 Tests (vitest) — directory lists ONLY public projects cross-org; ranking + search/filter correctness; cursor pagination

Done
Description

Estimate: 50m · Depends on: 6.13.2, 6.13.4

Lock the load-bearing guarantees: (1) the directory lists ONLY public projects cross-org (non-public excluded), (2) each rank orders correctly + deterministically, (3) search + category/tag filter are correct, and (4) pagination skips/duplicates no row. On a real Postgres (the standing rule), covering:

  • Public-only, cross-org. Seed public + non-public (private/open/limited) projects across MULTIPLE orgs. Assert the directory returns every PUBLIC project (including from orgs the requesting account has no membership in) and EXCLUDES every non-public project for every viewer; assert the card projection payload contains ONLY name + org + the three stats + description and NO internal project field. Assert an UNAUTHENTICATED (no-session) request SUCCEEDS and returns the same public list (the page is fully public — there is no account gate to reject it).
  • Ranking. With timestamped seed votes/activity: Trending orders by recent (windowed) signal (a fresh upvote burst lifts a project above a higher-lifetime-but-stale one); Popular orders by lifetime totals; Recent orders by made-public time. Assert each rank is a DETERMINISTIC total order (stable id tiebreak — the same input yields the same order twice).
  • Search + category/tag. A name/description query returns only matching public projects; a category/tag filter returns only public projects with that tag; search + tag + the rank tab COMPOSE; the tag-facet counts only public projects. No user string reaches SQL unparameterized (the 6.1.1 injection posture, extended to the directory search).
  • Cursor pagination. Paging each rank past a page boundary returns every row exactly once (no skip, no duplicate) over the keyset cursor; the read is bounded (not load-all).

Acceptance criteria

  • The public-only-cross-org guarantee is asserted (every public project listed, every non-public excluded, the projection leaks no internal field, an unauthenticated request succeeds — fully public).
  • Each rank’s ordering + determinism, the search + category/tag filter correctness + composition, the tag-facet public-only count, and the cursor no-skip/no-dupe pagination are each asserted.
  • New service/repository code respects the per-file coverage gate (CLAUDE.md § coverage); the empty-directory / empty-search / empty-category guards each have a direct test; tests use the real Postgres helper.

Context refs

  • 6.13.2 (the directory + projection + cursor), 6.13.3 (search + category/tag), 6.13.4 (the ranks), 6.13.5 (the tag-facet count).
  • motir-core/CLAUDE.md § tests-use-real-Postgres + the per-file coverage gate.
  • motir-core/tests/helpers/db.ts — the per-test truncation harness.