Repository navigation
test(web): pin what the collection pages and editors save today - #1912
Conversation
The collections redesign rewrites every editor, the user page and Add to collection. These tests record the exact v2 requests today's pages send, so each later change to a body, an ETag or a call order shows up as a deliberate golden diff instead of a silent regression. A recorder stands in for the v2 request boundary: it answers from the contract fixtures, tracks an ETag per resource (item writes move the collection's, a stale If-Match gets 412), and checks the wire rules after every test: If-Match on guarded writes, string library ids, collection_type on admin PATCH, and no query_definition or sort_config for manual collections. The goldens include today's known gaps on purpose: the editor PATCH carries featured, personal bodies carry no description, a personal poster removal is sent before Save, imports default to featured, and adding a title on the personal manual page leaves Save with a stale ETag that answers 412. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Every path used to start at the same "rev-1", so a guarded write passed even when it sent another resource's ETag, such as the list's instead of the collection's. The recorder now names the path in each ETag, so the upcoming ETag refactor fails a golden if it reads the wrong resource. Also pin the bundle apply job with Delete Existing on, the request that deletes server collections, and mark two pinned gaps for the steps that fix them: dnd-kit announces collection ids instead of names on Your collections, and a downward move on the groups board saves one slot above where the preview showed it. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Six test comments named steps from an unpublished working plan, which mean nothing to other contributors. They now say what the gap is and that a fix should change the golden on purpose. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 300454a876
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| await act(async () => { | ||
| fireEvent.keyDown(first!, { code: "Space" }); | ||
| // The sensor starts listening for arrows on the next task. | ||
| await new Promise((resolve) => setTimeout(resolve, 0)); |
There was a problem hiding this comment.
Replace the timer with an observable drag-state wait
This test assumes one setTimeout(0) task is enough for the keyboard sensor to become active; if dnd-kit schedules activation differently or CI timing changes, the arrow events can arrive before the sensor is ready and produce a flaky failure. Wait for an observable drag state or live-region change instead. The same fixed-delay pattern also appears in Collections.smoke.test.tsx.
AGENTS.md reference: AGENTS.md:L168-L170
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Not a timing risk. The Space keydown creates the KeyboardSensor synchronously (instantiateSensor in DndContext), and its attach() queues setTimeout(() => this.listeners.add("keydown", ...)) with no delay. The test's own setTimeout(resolve, 0) is queued after that, and timers with equal delay fire in registration order, so the arrow keys always reach an attached listener regardless of CI load. There is also no observable state to wait on: the "picked up" announcement and drag state are set in handleStart() before the listener is attached, so waiting on them would be weaker than the timer. The lockfile pins @dnd-kit/core 6.3.1; if an upgrade changes the scheduling, the golden fails outright rather than intermittently. The same reasoning covers the one timer in Collections.smoke.test.tsx.
Problem
Related issue: #192
Validation tasks: none
The collections redesign will rewrite every collection editor, the Collections page and Add to collection. No test checks the exact v2 requests those screens send today, so a changed request body, a missing or stale If-Match, or a reordered artwork call could ship without a failing test. This PR records what today's pages and editors send, so each later change in the redesign shows up as a deliberate golden diff. It changes no production code.
Stacked on #1909 (
test(web): run the catalog page tests again).Approach
web/src/test/v2Recorder.tsmocks@/api/v2/request. It records each request's operation, path, query, headers and body, and answers fromcontracts/api/v2/fixturesor from a test's own answer; a request with no answer fails the test. It keeps one ETag per resource, with the path in the value. An item write also moves its collection's ETag. A guarded write whose If-Match is stale, or belongs to another resource, gets a 412 carrying the current ETag, as the server sends.library_id/library_ids,collection_typeon every admin PATCH, and noquery_definitionorsort_configin a manual collection's body. No assertion reads a personal collection'sgroupsorgroup_id, so regenerated fixtures without them won't break these tests.web/src/test/fixtures/collectionBodies.ts. They cover admin and personal create and update for manual and smart collections, with artwork call order; smart collections saved unchanged with no limit, the 10,000,000 sentinel and a limit of 250; MDBList and TMDB imports and the template forms; the imported-collection edit PATCH for each source; admin staged artwork; template bundle dry runs and apply jobs with heroes on and off and with Delete Existing; and Add to collection for a regular profile and an acting admin.Some of today's behaviour looks wrong but is pinned on purpose, so the change that fixes it has to update the golden and say why:
featured, and imports default tofeatured: true.description.poster_source_urlin the POST body; the poster PUT runs only for an uploaded file.query_definition.library_idsgo out as numbers while the top-levellibrary_idsare strings. The string check covers the top level only.source_configback unchanged.ImportedCollectionEditorPATCH always sendsname,is_shared,library_idsandinclude_in_server_collections; only the optional fields are sent when changed.Validation
tsc -b), budget:check andmake test-webpass.make verify-local-pathspasses.Risks
None identified for the product; the change is test-only. The two keyboard smoke tests stub
getBoundingClientRectto lay out the rows and the dnd-kit drag overlay, so a dnd-kit upgrade that measures differently could break them.Checklist
AI Disclosure
descriptionadded to the personal PATCH,featureddropped from the admin PATCH, the templatefeatureddefault, the dry run'sdelete_existing, and the admin add-item route. Each edit failed the matching golden. It also checked the guarded writes against every contract operation that requires If-Match. It found one major problem: every resource started with the same ETag, so a write that sent another resource's ETag still passed. ETags now include the path, and a recorder test covers the wrong-resource case. Of three minor findings, one was fixed: the apply job with Delete Existing on was not pinned, so a golden was added and checked by forcing the flag off. The other two, the id-based announcements and the groups board's downward move, are known behaviour, now marked in test comments and listed above.🤖 Generated with Claude Code
Note
Add golden and smoke tests for collection pages, editors, and dialogs
AddToCollectionDialog,GroupsBoard, and the template gallery bundles.Macroscope summarized 300454a.