store: cover cart.ts with tests, drop unused Tailwind, fix stale copy #49
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Three unrelated small things, batched because each is a few lines and none deserves its own issue.
1.
lib/cart.tshas no testIt is the only module in
apps/store/libwithout one, and it is the riskiest: it owns money-adjacent state, treatslocalStorageas a trust boundary viaisLine(), keeps a module-level store with a listenerSet, and syncs across tabs onStorageEvent. #41 and #47 both change the cart line shape, so the coverage should exist before they land, not after.Worth asserting: a malformed stored value yields an empty cart rather than throwing;
addof an existing slug increments instead of duplicating;setQty(0)removes the line;totalexcludes null-price lines andhasUnpricedLinereports them; listeners fire on mutation. The hook needs no DOM — export the store functions and test those, keepinguseCartas the thin wrapper.2. Tailwind is installed but never used
tailwindcssv4 and@tailwindcss/postcssare inapps/storedevDependencies and wired inpostcss.config.mjs, butglobals.csshas no@import "tailwindcss"and no component uses a utility class. All styling is the plain-CSS token system from #33. Delete both dependencies and the postcss wiring — it is install weight and a misleading signal to the next reader about how this app is styled. (apps/managementgenuinely uses Tailwind; leave it alone.)3. Pre-cart copy on the products page
app/products/page.tsxmetadata and lead still say "tanya stok dan harga lewat WhatsApp". Prices and a cart shipped in #39 — the copy predates them and now undersells the page. Reword to match the shipped behaviour.Acceptance
pnpm --filter garage-store testcovers the cart cases above and passes.pnpm installno longer pulls Tailwind for the store, andpnpm --filter garage-store buildproduces a visually identical site (the postcss pipeline was a no-op). No page still tells visitors to ask for prices they can see.