refactor(link-wizard): give the queue a module - #446
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
🟡 Changes recommended
The new queue hook currently reports position: 1 when the queue is empty (inconsistent state), and the new tests couple to useLinkWizardSkipped’s localStorage schema instead of its public API.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR refactors the Link Wizard’s “queue navigation” into a dedicated useLinkWizardQueue hook, moving selection, stage filtering, and skip/save-then-advance logic out of LinkWizard.tsx and tightening the UI wiring.
Changes:
- Added
useLinkWizardQueuehook to own filtered queue state, current selection, and navigation actions. - Updated
LinkWizard.tsxto delegate queue behavior to the new hook and simplify the page component. - Updated
LinkWizardQueue.tsxto own the mobile “View all” preview toggle locally and removed related props; added hook tests for queue behavior.
File summaries
| File | Description |
|---|---|
| src/pages/admin/festivals/LinkWizard/useLinkWizardQueue.ts | New queue hook centralizing filtering + navigation and exposing a small semantic interface. |
| src/pages/admin/festivals/LinkWizard/useLinkWizardQueue.test.ts | New hook tests covering filtering, selection, prev/skip/save behavior, and post-filter consistency. |
| src/pages/admin/festivals/LinkWizard/LinkWizardQueue.tsx | Moves mobile preview “View all” state into the queue UI component and trims prop surface. |
| src/pages/admin/festivals/LinkWizard/LinkWizard.tsx | Replaces ad-hoc queue/index math with useLinkWizardQueue and wires actions through to the UI. |
Review details
Suppressed comments (1)
src/pages/admin/festivals/LinkWizard/useLinkWizardQueue.test.ts:142
- This test asserts save persistence by reading
localStorageand relying on the internal storage schema ofuseLinkWizardSkipped(stored[EDITION_ID].records[...]). That couples the test to storage internals instead of the hook’s public API.
const stored = JSON.parse(localStorage.getItem("link-wizard-skipped")!);
expect(stored[EDITION_ID].records["1"].status).toBe("saved");
});
- Files reviewed: 4/4 changed files
- Comments generated: 2
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Playwright test resultsDetails
|
Deepen useLinkWizardQueue to own stage filtering, position, and skip/save-then-advance behavior, replacing the ad-hoc state and index math previously spread across LinkWizard.tsx. useLinkWizardSkipped stays a separate module, passed in as a dependency to keep a single localStorage-backed instance shared with the skipped/saved popover. Closes #445 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1f59dde to
1a25a25
Compare
…storage schema Report position 0 (not 1) when the queue is empty, matching total: 0 and an undefined currentItem. Assert skip/save persistence through useLinkWizardSkipped's public API instead of parsing localStorage directly, per Copilot review on #446. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Deepens the Link Wizard's queue navigation into
useLinkWizardQueue, replacing the ad-hoc state and index math spread acrossLinkWizard.tsx.useLinkWizardSkippedstays a separate module, passed in as a dependency so the popover and queue share one localStorage-backed instance.Closes #445
Verification