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.
A teammate’s pull request adds signing in and out. Signing in merges the saved cart into the guest cart (at most 9); the author loads it quietly because restoring “isn’t a change the shopper made”. Signing out empties the cart and clears every registration, “so the old session’s views stop hearing about it”. QA reports that after signing in, the badge and the open panel still show the guest quantity, and that after signing out, the badge stops updating altogether. You are reviewing the pull request.
Shoppers see a quantity that is not in their cart until something else changes it, and after signing out the header badge is frozen for as long as the page is open.
Reproduce With 2 items saved: sign in, then sign out. The badge should show 0, 2, 0 and stay subscribed. Today it shows only 0, and the cart ends with no registrations at all, so nothing after sign-out reaches the badge either.
Acceptance criteria Signing in merges the saved quantity (at most 9), and every registered view hears the result once; a merge that changes nothing reaches nobody. Signing out empties the cart, and every view still on the page hears 0 and keeps hearing later changes. Registrations end only when their owners end them; OBSERVER-101’s and OBSERVER-102’s rules still hold. Keep the quiet load and the clear-everything only if they are right for every view they touch; otherwise remove them. Notes runCart builds a fresh page per case with the case’s saved quantity; its steps are open, close, notice, dismiss, sign-in, sign-out, or a quantity to set. Keep it, and the names of the sign-in and sign-out functions. Cases print “badge […] · panel […] · notice […] · registrations n”, as in OBSERVER-102.