One cart, a badge that stays, views that come and go
The cart session from the lesson: a header badge that stays on the page, a cart panel the shopper opens and closes, then an “Added to cart” notice, then signing in and out. Each level starts from the previous level’s finished code, so you can begin at any of them.
Product pages gain an “Added to cart” notice. When the shopper presses Add, the notice waits for the cart’s next change (the server confirms the add a moment later) and shows the new quantity once. The shopper may dismiss it before that change arrives, and may press Add again later.
A notice that keeps its registration pops up on every later change, including ones the shopper made in the panel, and each press of Add adds another registration, so the pop-ups multiply.
Reproduce Press Add (notice), then change the quantity to 1. The notice should show 1, and afterwards the cart should hold only the badge’s registration. Today it still holds the notice’s, so the next change, 2, pops the notice up again.
Acceptance criteria After Add, the notice shows the next change only, and the cart no longer holds its registration. A dismissed notice shows nothing; pressing Add again waits for the next change, once. Writing the current quantity again is not a change: a waiting notice keeps waiting. Every other registration still hears the change that ends the notice’s, whatever order they registered in; the panel’s and the badge’s rules from OBSERVER-101 still hold. Notes runCart builds a fresh page per case; its steps are open, close, notice (the shopper pressed Add), dismiss, or a quantity to set. Keep it, and the names of the views’ methods. Cases print “badge […] · panel […] · notice […] · registrations n”: each view’s renders, the quantities the notice showed, and the registrations the cart holds at the end. The notice may end its registration itself or ask the cart for a one-shot registration; either is fine, as long as the cases pass.