Repository navigation
test: cut change amplification in the unit lane - #1136
Conversation
Every PR that added a spec had to bump the file and test counts in tests/PERF.md and three or four consumer docs: all 28 commits touching PERF.md since 2026-10-20 did. The docs now point at PERF.md for counts, and perf-figures-pinned keeps only the two tier-target checks (#990). Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ing them - atlas-translations-schema: the key and leaf-group counts become floors; 7 of the case's 10 edits only bumped the exact numbers. - locales, filterAvailableLocales: compare against LOCALES rather than a hand-written 19-code array and length. - json-field-schemas: validate buildDefaultNotificationPreferences() rather than a copy of it. - admin-locale-urls: drop the call-site count from the header comment. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…is the point - One local renderHtml() per email spec, so a renderEmail return-shape change costs one line instead of ~40 call sites (fd18755). - Sign-in and verify URLs passed in as fixtures are neutral (https://cloud.test/x?t=1), not real routes; manager-auth-urls pins the real shape. Those literals changed twice (4f0b06a, 8971cc1). - Copy assertions are kept only where the wording is the contract; elsewhere the specs check the href, the locale, or the value present. - Registration question labels come from EVENT_REGISTRATION_QUESTIONS and the key fallback from toWords, not restated strings. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s prose openapi-custom-endpoints had 24 edits since it was written, and all 11 that changed existing lines came from renames, copy edits or deleted endpoints, not from anything it imports. It drops 28 per-endpoint path, parameter and description assertions (51 cases to 18) and gains structural checks: - every documented method and path is one the sanitized config registers; - every $ref resolves to a declared schema or a generated collection one; - documented root endpoints stay visible in each project spec, and are hidden when not declared as root paths, read from the config. The config-reading cases sit in sanitized-config-rules, which already pays the ~6.5 s config import, so no new spec loads @/payload.config. Visibility filtering, the calendar feed's security: [], the transcript hiding, and the enums sourced from constants keep their cases. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…trix - audiences, user-choices, pages, meditations: 17 cases asserting plain CRUD, required, field defaults or draft status on fields with no hook or validate of ours (tests/AGENTS.md: do not test Payload internals). - meditation-lectures, lectures-for-audience, app-cards-for-audience: the empty / non-numeric / normalisation cases for ?audiences, which every handler parses with audiencesQueryParamSchema and unit/audiences-query-param covers. "missing -> 400" stays in each as the wiring proof. - retention-jobs, event-imports, screen-submissions: one case each that repeats a pure unit case with no wiring added. event-feedback's mixed-verdict case and user-submissions-create's rich-text scan stay: each is the only int proof of its wiring. Co-Authored-By: Claude Opus 5.5 <[email protected]>
isEventInUserDaytime and isScheduleActiveNow (#348) have no consumer in src, scripts or seeds; only their own specs imported them, and those specs still cost edits in type sweeps (cf5e09e). The code and its 28 cases go together. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… one home each - event-title-cache: drop its three helper cases; event-title.spec holds the same inputs and outputs, and both were edited together twice. - manager-signin-urls: its "one redeem route" case was already in reminder-button-url; the escaping case moves there and the file goes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ices in the mounted tab activeSegmentIndex's whole-second and pause cases live in meditation-transcript-model.spec, and the stall bound in transcript-phase.spec. The jsdom tab keeps one case per wiring: the mark follows the playhead, sits on the focusable phrase, and the stall notice appears while mounted (now also asserting the copy names no duration). Co-Authored-By: Claude Opus 5.5 <[email protected]>
storage-utils (57 cases), cloudflare-stream-webhook (25) and translations-field (26) never call createTestEnvironment() and need no .env; each paid the int lane's setup and a fork for pure functions. tests/AGENTS.md already cited the first two as unit-lane examples. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Five rules aimed at the causes of most spec edits that changed no behaviour: restated counts and lists, docs quoting lane counts, copy pinned in many places, the same matrix in several specs, and a call shape repeated across dozens of sites. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
🚅 Deployed to the SahajCloud-pr-1136 environment in sahajcloud
1 service not affected by this PR
|
|
@sydevs-bot review |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The PR does what its body says, and the spot checks hold: retention-jobs' deleted "declares no retention" case already exists at tests/unit/retention-discovery.spec.ts:111 with the same message, screen-submissions keeps seven verdict: 'ok' cases, and daytimeMatch/scheduleMatch have no consumer because the eventTime and schedule fields #348 read are gone from the collection. The OpenAPI commit is a net gain, not a cut: filterSpec visibility and the depth cap now derive from the sanitized config instead of a hand-listed path per endpoint. No product code rides along beyond the two dead modules the body names. Two cuts go further than change amplification warrants.
Findings
- should-fix — the perf commit also drops the doc-to-PERF.md timing agreement, which only reddened on a re-measurement.
tests/unit/perf-figures-pinned.spec.ts:56 - should-fix — the reworded
eventUrl: nullcase can no longer fail.tests/unit/event-verification-email.spec.ts:150 - consider — the structural check covers documented ⊆ registered only, not the direction the deleted cases named.
tests/unit/sanitized-config-rules.spec.ts:423
What was checked
Read whole on the branch: perf-figures-pinned, sanitized-config-rules, openapi-custom-endpoints, tests/PERF.md, tests/AGENTS.md, audiences/resolve.ts, Audiences.ts. Ladder: no new file, type or dependency; renderHtml and normalisePath are each local to one spec. 203 / 2643 is the second session's own row (PERF.md:68), not a rewritten figure. Grepped src scripts seeds tests docs for the deleted matchers: specs only. Confirmed rootEndpointPathsFrom and the maxDepth cap survive the OpenAPI cut, now config-derived. The three moved specs call no createTestEnvironment(). No preview link in the body; CI still running.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The perf commit dropped the doc-to-PERF.md timing agreement along with the count pins, but PERF.md still declares itself the single writer of every timing the three-tier contract states. Nothing then held the four docs' 78 s to the 77.9 s recorded here, which is the drift #990 was filed for — and unlike the count pins, this case only reddens on a re-measurement, so it costs no edit on a PR that adds a spec. The count pins stay gone. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
`baseProps` carries no `eventUrl`, so `not.toContain(EVENT_URL)` could not fail however the template behaved — dropping the `eventUrl ?` guard left it green. The secondary button's own fill and border is the fingerprint instead: no label is restated, and the variant is only ever this one button. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
The structural check held documented ⊆ registered only. The failure the deleted per-path cases named is the other direction — an endpoint missing from the hand-written shim is invisible in /api/docs with nothing going red — and nothing covered it: renaming the geojson path left the lane green. The rule is derived from the raw collection barrel, so adding an endpoint needs no new case. Six manager-only endpoints are exempt by name, each authenticating a manager and accepting no client API key; a second case reds when an exemption outlives its endpoint. It is its own file because `buildConfig` mutates those raw configs in place, appending Payload's 440-odd REST routes, so this must not share a module graph with `@/payload.config`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWHA66mbAPfDH65QWr
|
All three review threads adopted. Pushed for relay as
Base was already current, so no merge. Lean gate green: 269 files, 3,629 tests. Each case was watched failing against the real defect. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…w endpoint #1136 stopped the docs quoting the unit lane's file and test counts, and `perf-figures-pinned` no longer pins them. This branch's last two commits existed only to re-pin those counts, so all four doc hunks take main's side: the counts go, the PERF.md session table keeps this branch's own measured rows. #1136 also replaced `openapi-endpoint-coverage`'s per-endpoint assertions with a structural check, which this branch's new `POST /api/clients/:id/email-preview` then failed. It authenticates a manager and takes no client API key, so it joins MANAGER_ONLY beside `verify-embed`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXyxHTrvBwd12hmgi6
Four doc conflicts, all the same one: #1136 stopped pinning the unit lane's file and test counts anywhere but tests/PERF.md, and this branch had bumped those counts in all four docs. Took main's side in each — the counts it removed are the ones no doc may quote now. tests/PERF.md keeps main's `Files / tests (second session)` row: that row is the second session's record now, not the current tree's. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXimsbUmfehpBf19
#1136 landed a check that every collection endpoint an API client can call is in the hand-written OpenAPI document. This branch's two secret routes are not callable by a client: both run requireActiveManager and refuse an API key, so they belong in the same exemption list as the Registrations CSV download. Recorded the merged tree's lane measurement in tests/PERF.md. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWVXimsbUmfehpBf19
#1136 cut change amplification out of the unit lane: it took the file and test counts out of every doc and spec that quoted them, leaving `tests/PERF.md` as their one home. This branch had bumped those same counts. Every doc hunk takes main's side — AGENTS.md, testing-reqs.md, tests/AGENTS.md, and PERF.md's second-session metric row, which is a measurement and not this branch's to replace. `admin-locale-urls.spec.ts` is the same conflict in a docblock: main stopped counting the call sites, this branch had counted a fifth. Main's wording stays correct as sites are added, so it wins. `meditation-transcript-tab.spec.ts` keeps both intents. Main deleted the standalone stall case as redundant and moved its no-duration assertion into the fake-timers case it kept; this branch's copy change — these notices are titles, so no full stop — stays on every assertion. One semantic consequence, fixed rather than merged: #1136's new `openapi-endpoint-coverage.spec.ts` requires every client-callable collection endpoint to be in the OpenAPI document, and this branch adds `POST /api/files/:id/transcribe`. That endpoint gates on `requireManagerPermission` and takes no client key, exactly like the meditations twin already exempted there, so it joins `MANAGER_ONLY` with its reason. main added no migration since the merge base, so no snapshot repair. Lean gate green on the merge: lint, format:check, typecheck, typecheck:tests, test:unit (272 files, 3712 tests, 52.28 s). Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjX2b1oZam54PpdTewz
… the type list Main's #1136 keeps a matrix in one home. The mounted field needs only to show it reads the stored type and the chosen file's, so the video rows go. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Summary
The unit lane has little true redundancy. Its edit cost comes from specs that restate what the source already enumerates: counts, lists, email copy and URLs, and the prose of a hand-written OpenAPI document. Over the last 6 months those specs were edited in commits that never touched their subject. This PR removes or rewrites them, deletes one pair of dead modules, and moves three pure specs out of the integration lane.
Each commit is one category, so each can be reviewed alone:
test(perf)perf-figures-pinnedstops pinning the file and test counts to the tree and to four docs. The docs point attests/PERF.md; the two tier-target checks stay, and so does the doc-to-PERF.md lane-timing agreement, which only reddens on a re-measurement. All 28 commits touching PERF.md since 2026-10-20 bumped those counts. Reverses part of #990's design.test(unit): derive…LOCALES; notification default derives frombuildDefaultNotificationPreferences()test(email)renderHtmlhelper per email spec; fixture URLs are neutral; copy asserted once per template; registration labels come from the question configtest(openapi)$refresolves. The config-reading cases live insanitized-config-rules, so no new spec imports@/payload.configopenapi-endpoint-coverage(+5 in sanitized-config-rules)test(int)refactor(audiences)daytimeMatch.tsandscheduleMatch.ts(#348) and their specs: no consumer insrc,scriptsorseedstest(unit): …one home eachevent-title.specdropped;manager-signin-urlsfolded intoreminder-button-urltest(transcripts)test: move…storage-utils,cloudflare-stream-webhookandtranslations-fieldmove from the int lane to the unit lane. None callscreateTestEnvironment()docs(tests)tests/AGENTS.mdfor keeping specs cheap to changeDeliberately kept
login-plugin's exactWIRED_ROUTES,PUBLIC_CREATE_PATHS, and thejob-scheduleslist: an extra entry is the bug.schedule-hooksDST cases.client-origin-enforcement,role-based-access, andusage-tracking-dedup.cache-policy's literal list of cacheable globals: it is an allowlist of what reaches the edge cache.event-feedback's mixed-verdict int case anduser-submissions-create's rich-text scan: each is the only int proof of its wiring.Review follow-ups
Three cuts went further than change amplification warranted, and are now restored or replaced:
perf-figures-pinnedkeeps the four docs' lane timing held to PERF.md's recorded figure.event-verification-email'seventUrl: nullcase asserts the secondary button's own fill and border, so it can fail; the reworded version could not.openapi-endpoint-coverage.spec.tsholds registered ⊆ documented, the direction the deleted per-path cases were about. It is its own file becausebuildConfigmutates the raw collection configs in place, so it cannot share a module graph with@/payload.config.Test plan
typecheckandtypecheck:testspass.pnpm test:unit: 269 files, 3,629 tests passed, 53 s.eventUrl ?guard removed, the geojson path renamed, andsetProjectunregistered.ics-builder.spec.tsfails locally outside UTC: it expectsLAST-MODIFIED:20260801T100000and gets…T030000on MST. That spec comes from #1134 onmain, and this PR does not touch it. CI runs in UTC.🤖 Generated with Claude Code