Repository navigation
Conversation
The vitest suite (147 files, ~1235 tests) is dense on utilities but every
test is single-layer: the client/server seam is always cut with vi.mock or
a stubbed fetch. That is why the org.hypercerts.context.attachment
allowlist gap shipped — client and server were each correct, only the pair
was wrong. Adds the two layers that can see a mismatch.
Tier 1 — contract tests, no browser:
- indexer operation contract: scans src/ for every operationName passed
to postIndexer/getIndexer and asserts it exists in the server's
OPERATIONS map. A missing entry is a 400 at runtime and invisible to
every other test. Currently 20 call sites, 19 distinct operations.
- public-read-methods: pins the signed-out read boundary behaviourally
(getRecord/listRecords/getBlob public; everything else 401) so it
cannot silently widen or narrow.
Tier 2 — Playwright, no credentials. /dev/preview/{surface} already mounts
the real production components against fixtures via MockFetchProvider; it
was only ever driven by the screenshot script. Adds playwright.config.ts
plus specs covering the 8 surfaces across populated/empty/managed
scenarios and dark mode, and a signed-out walk of the public routes
asserting no console errors or uncaught exceptions. 39 pass in ~17s
against next dev, with no ePDS, Redis, or indexer access.
Tier 3 — authenticated flows, scaffolded and skipped by default. There is
no password grant (OAuth + emailed OTP), but the cookie and OAuth halves
of a session are stored independently, so one interactive login for a
throwaway account lets global-setup mint cookies for 30 days. Ships the
update create/edit/delete lifecycle spec; skips cleanly without
E2E_TEST_DID so CI and forks are unaffected.
Also: the preview harness mocks fetch client-side only, so its SSR/client
hydration mismatch is structural — tolerated on /dev/preview only, never
on real routes, which hydrate clean today.
Housekeeping: AGENTS.md claimed in three places that no tests exist; adds
§27 documenting the layout, the contract-test rule, and the CSRF origin
discipline that makes these suites reproducible. Removes two manual test
plans covering the retired /groups index and the removed notifications
system. Wires @testing-library/jest-dom and a global afterEach(cleanup)
into test-setup.ts — both were dependencies that were never imported.
Verified: tsc, typecheck:test, lint clean; 1245 vitest tests pass;
39 e2e pass / 4 skip. Removing the collection from ALLOWED_WRITE_COLLECTIONS
fails the contract test in 32ms.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThe pull request adds Vitest contract tests and Playwright coverage for API boundaries, public routes, preview surfaces, and authenticated update lifecycles. It also adds local authentication setup, CI execution, shared helpers, and testing documentation. ChangesAutomated testing
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant CI
participant Playwright
participant DevServer
participant Redis
CI->>Playwright: Start browser tests
Playwright->>DevServer: Run E2E scenarios
Playwright->>Redis: Use seeded authenticated session when configured
DevServer-->>Playwright: Return rendered pages and API responses
Playwright-->>CI: Report test results and failure artifacts
Possibly related PRs
Suggested reviewers: ✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Adds the test layers that can catch a client/server mismatch, plus the doc and setup fixes that go with them. One commit, 16 files.
Why
The vitest suite (147 files, ~1235 tests) is dense on utilities but every test is single-layer — the client/server seam is always cut with
vi.mockor a stubbedfetch. That is precisely how theorg.hypercerts.context.attachmentallowlist gap shipped in #241: the client sent the right collection, the server correctly rejected non-allowlisted collections, and each side passed its own tests. Only the pair was wrong.Tier 1 — contract tests, no browser
src/for everyoperationNamepassed topostIndexer/getIndexerand asserts it exists in the server'sOPERATIONSmap. A missing entry is a runtime 400 that no other test can see. Currently 20 call sites, 19 distinct operations, all present.public-read-methods— pins the signed-out read boundary behaviourally (getRecord/listRecords/sync.getBlobpublic, everything else 401), so it can neither silently widen nor narrow.Tier 2 — Playwright, zero credentials
/dev/preview/{surface}already mounted the real production components against fixtures viaMockFetchProvider; it had only ever been driven by the screenshot script. It is now a test suite:?fixture=empty/?managed=1/ dark modeRuns as a separate
e2eCI job so a flaky browser run is distinguishable from a broken build, and so it does not extend the critical path.Tier 3 — authenticated flows, skipped by default
There is no password grant (OAuth + emailed OTP), but the cookie and OAuth halves of a session are stored independently and the OAuth half is keyed only by DID with a 30-day TTL. So one interactive login for a throwaway account lets
global-setupmint cookies for a month. Ships the update create/edit/delete lifecycle spec — the flow that broke — and skips cleanly withoutE2E_TEST_DID, so CI and forks are unaffected.Housekeeping
AGENTS.mdclaimed in three places that no tests exist. Replaced with §27 documenting the layout, the contract-test rule, and the CSRF origin discipline (host spelling + pinned port) that makes these suites reproducible./groupsindex and the removed notifications system — both described features that no longer exist.@testing-library/jest-domand a globalafterEach(cleanup)intotest-setup.ts; both were already dependencies that were never imported.Known tolerance
The preview harness patches
fetchclient-side only, so SSR renders empty while the client renders populated — a structural hydration mismatch. It is tolerated on/dev/previewonly, never on real routes, which hydrate clean today.Verification
tsc,typecheck:test, andlintclean. 1245 vitest tests pass. 39 e2e pass, 4 skip. Removingorg.hypercerts.context.attachmentfromALLOWED_WRITE_COLLECTIONSfails the contract test in 32ms and passes again when restored.🤖 Generated with Claude Code
Summary by CodeRabbit
Quality Improvements
Developer Experience
Documentation