Skip to content

test(web): pin what the collection pages and editors save today - #1912

Merged
Quick104 merged 3 commits into
feat/collections-revampfrom
test/collections-editor-goldens
Oct 4, 2026
Merged

Quick104 merged 3 commits into
feat/collections-revampfrom
test/collections-editor-goldens

Conversation

@Quick104

@Quick104 Quick104 commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

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.ts mocks @/api/v2/request. It records each request's operation, path, query, headers and body, and answers from contracts/api/v2/fixtures or 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.
  • After every test the recorder checks the wire rules: If-Match on every guarded write, string top-level library_id/library_ids, collection_type on every admin PATCH, and no query_definition or sort_config in a manual collection's body. No assertion reads a personal collection's groups or group_id, so regenerated fixtures without them won't break these tests.
  • The goldens run through the real pages and hooks and are named in 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.
  • Smoke tests cover the admin groups board (render and one keyboard move), the Your collections keyboard reorder with its screen-reader announcements, Shared with me cards with no buttons (Collections — Web #195 W7 as published), and a single-profile account that still shows Server collections (Collections — Web #195 W1 as today).

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:

  • The admin editor PATCH sends featured, and imports default to featured: true.
  • Personal create and PATCH send no description.
  • Removing a personal poster sends the DELETE when clicked, before Save.
  • On the personal manual page, adding a title moves the collection's ETag, but a later rename saves with the ETag the page loaded with, so the server answers 412.
  • Personal create sends a pasted poster URL as poster_source_url in the POST body; the poster PUT runs only for an uploaded file.
  • In admin smart collections, query_definition.library_ids go out as numbers while the top-level library_ids are strings. The string check covers the top level only.
  • The Trakt edit PATCH sends the stored source_config back unchanged.
  • The ImportedCollectionEditor PATCH always sends name, is_shared, library_ids and include_in_server_collections; only the optional fields are sent when changed.
  • The bundle apply job with Delete Existing on goes out with no confirmation step.
  • Your collections drag announcements read collection ids instead of names.
  • On the admin groups board, a downward keyboard move saves the collection one slot above where the drag preview showed it.

Validation

  • Web: lint (no errors; every warning is in a file this PR doesn't touch), format:check, build (which runs tsc -b), budget:check and make test-web pass.
  • The new tests pass in default order and in shuffled order.
  • make verify-local-paths passes.
  • No Go, contract or migration files changed, so the Go and contract checks were not run.

Risks

None identified for the product; the change is test-only. The two keyboard smoke tests stub getBoundingClientRect to lay out the rows and the dnd-kit drag overlay, so a dnd-kit upgrade that measures differently could break them.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.

AI Disclosure

  • Harness: Claude Code (in T3 Code)
  • Tool(s): Claude Code subagents (implementer, independent reviewer)
  • Model(s): claude-opus-5-5[1m]
  • Involvement: Fully AI-generated, human review pending
  • Adversarial review: An independent reviewer subagent read the diff and ran the new tests three times in shuffled order. To check that the goldens catch real changes, it edited production code in a throwaway copy: a stale personal If-Match, a description added to the personal PATCH, featured dropped from the admin PATCH, the template featured default, the dry run's delete_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

  • Pins current behavior of collection editors with golden tests in CollectionForms.goldens.test.tsx and CollectionImports.goldens.test.tsx, comparing exact recorded request sequences for admin and personal manual, smart, and synced collection flows.
  • Adds a v2 request recorder in v2Recorder.ts that answers operations from fixtures, tracks ETags and revisions, and fails tests on unanswered calls or wire-invariant violations.
  • Adds Collections page smoke tests for keyboard drag-and-drop ordering, shared collections, and server collections, plus golden tests for AddToCollectionDialog, GroupsBoard, and the template gallery bundles.
  • Includes shared fixture data for capabilities, collection responses, and expected write payloads.

Macroscope summarized 300454a.

Quick104 and others added 3 commits October 4, 2026 08:56
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]>
@coderabbitai

coderabbitai Bot commented Oct 4, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a28c6e1d-e411-4dc1-8e0e-c21cf749d659

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 4, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-04T13:14:46.531630Z 300454a PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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));

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant