Transfer list with select-all, bulk moves, and adding items
A product team plans each sprint by pulling tickets from the backlog. Build the picker they use: two side-by-side lists, Backlog and Sprint, where tickets can be checked, bulk-selected, moved between the lists, and added on the fly.
The starter code includes the list names and the starting tickets:
const LISTS = ['Backlog', 'Sprint'];
const INITIAL_ITEMS = {
Backlog: [
{ id: 1, name: 'Audit color contrast' },
{ id: 2, name: 'Cache avatar images' },
{ id: 3, name: 'Fix login redirect' },
{ id: 4, name: 'Migrate to Vite' },
{ id: 5, name: 'Write API docs' },
],
Sprint: [
{ id: 6, name: 'Dark mode toggle' },
{ id: 7, name: 'Paginate search results' },
{ id: 8, name: 'Refactor focus trap' },
],
};
{List}: {checked} of {total} selected, for example Backlog: 0 of 5 selected.Select all in {List} (a <label> or aria-label). Its state reflects that list only:
checkbox.indeterminate = true) and unchecked when some, but not all, items are checked.Clicking it checks every item in that list, unless they are all already checked, in which case it unchecks them all.
Add to {List}. Pressing Enter adds the typed name to the end of that list, unchecked, and clears the input. Use a <form> or an Enter key handler, not both.
" Rate limit uploads " becomes "Rate limit uploads". A blank name does nothing."{existing name}" is already in {List}, naming the list that holds it.No items.Start Backlog: 0 of 5 selected Sprint: 0 of 3 selected
Move to Sprint and Move to Backlog are disabled
Check "Fix login redirect" Backlog: 1 of 5 selected
Select all in Backlog is indeterminate
Click Select all in Backlog Backlog: 5 of 5 selected, Select all in Backlog is checked
Click Select all in Backlog Backlog: 0 of 5 selected
Check "Migrate to Vite", then "Cache avatar images", click Move to Sprint
Backlog: Audit color contrast, Fix login redirect, Write API docs
Sprint: Dark mode toggle, Paginate search results, Refactor focus trap,
Cache avatar images, Migrate to Vite
Backlog: 0 of 3 selected Sprint: 0 of 5 selected
Add to Sprint: "fix LOGIN redirect" + Enter
nothing added, Sprint shows: "Fix login redirect" is already in Backlog
Click Select all in Backlog, then Add to Backlog: "Lazy load charts" + Enter
Backlog: 5 of 6 selected, Select all in Backlog becomes indeterminate
No items, a disabled select-all checkbox, and a disabled move button for that source.The tests click checkboxes and buttons, type into inputs, press Enter, and read the screen like a user would. You don’t need test ids, specific class names, or an exact HTML structure. They check that:
<input type="checkbox"> elements. An item checkbox’s label (a <label>, or aria-label) is the item’s name. The tests read checked, indeterminate and disabled on them.Select all in Backlog, Select all in Sprint, Add to Backlog and Add to Sprint (a <label>, aria-label or placeholder all work).disabled attribute (or aria-disabled="true").Backlog: N of M selected, Sprint: N of M selected, is already in Backlog, is already in Sprint and No items appear as described.Moved items can be removed from the page or hidden (hidden, display: none, or visibility: hidden). Capitalization and extra spacing don’t matter.