feat(web): checkout and order confirmation pages (#41) #126

Merged
amiryahaya merged 11 commits from feat/41-checkout-page into main 2026-10-29 13:31:08 +01:00
Owner

What

Checkout for the ticket site (web only, no Go changes). Refs #41.

  • /checkout: shows the server-priced cart lines, a required Promo code field, and Place order. Promo code is the only "payment" for now (payment_method: "wallet"), so Place order stays disabled until a code is entered. Other payment methods are parked.
  • /orders/:id: confirmation read from GET /v1/me/transactions/{id}. A free sale shows as completed. A pending sale shows a fixed "cannot take payment yet" message with the Nairobi expiry. Expired, unknown-currency and not-found cases have their own texts.
  • useCheckout: one Idempotency-Key per trimmed code, kept for retries and replaced after a 201. Cancels in-flight cart queries and empties the cart cache after a 201. Every non-201 outcome invalidates ["cart"], so a stale cart cannot place a second order.
  • Shared cart/LineInfo.tsx, a Checkout link on the cart page, nairobiDateTime in dates.ts.
  • Dev journey: deploy/dev-idp/seed-promo.sql (code E2E-FREE, 100%) and a real-IdP test in e2e-idp/cart.spec.ts. The API needs KWS_RATE_LIMIT=off for it. README and CLAUDE.md Layout updated.
  • Accessibility: axe checks for both pages in the mocked suite and in e2e-idp; focus moves to the pending status; navigation uses replace; an unmount guard (StrictMode-safe) stops state updates after leaving.

Not included (agreed): seats, tickets/QR, promo preview, customer cancel, other payment methods.

Reviews

Per-task reviews approved. Whole-branch dual pass: Pass 1 (ponytail) and Pass 2 (correctness, opus). Pass 2's main finding (stale cart after a refusal could allow a second order) is fixed. Pass 1 re-check after the fix rounds: no Must fix.

Results

  • make cover: 91.3% (minimum 80%). Go is unchanged, so this is the same figure as on main.
  • Web: 288 unit tests pass (31 files), typecheck clean, build passes.
  • scripts/web-e2e.sh: 124 passed, 46 skipped (run before the last test-only commit).
  • pnpm --filter @kws/ticket e2e:idp: 7 passed against a local API (rate limit off). Not in CI.

Known / accepted

  • No customer cancel: a pending sale just expires at expires_at.
  • Place order is not disabled for unavailable lines; the server's 422 and the line note cover it.
  • A pending or order page does not flip to "expired" until it re-renders.
  • A failed background cart refetch after a promo refusal shows the cart error box.
  • The mocked layout spec does not cover /checkout and /orders/x (320px / 44px targets).
  • No unit test for the replace-navigation.
  • E2E-FREE seed is dev-only and has no database guard.

Not verified

Real phones, Safari/Firefox, Zitadel, and the real-IdP journey in CI.

🤖 Generated with Claude Code

## What Checkout for the ticket site (web only, no Go changes). Refs #41. - `/checkout`: shows the server-priced cart lines, a required **Promo code** field, and **Place order**. Promo code is the only "payment" for now (`payment_method: "wallet"`), so Place order stays disabled until a code is entered. Other payment methods are parked. - `/orders/:id`: confirmation read from `GET /v1/me/transactions/{id}`. A free sale shows as completed. A pending sale shows a fixed "cannot take payment yet" message with the Nairobi expiry. Expired, unknown-currency and not-found cases have their own texts. - `useCheckout`: one `Idempotency-Key` per trimmed code, kept for retries and replaced after a 201. Cancels in-flight cart queries and empties the cart cache after a 201. Every non-201 outcome invalidates `["cart"]`, so a stale cart cannot place a second order. - Shared `cart/LineInfo.tsx`, a Checkout link on the cart page, `nairobiDateTime` in `dates.ts`. - Dev journey: `deploy/dev-idp/seed-promo.sql` (code `E2E-FREE`, 100%) and a real-IdP test in `e2e-idp/cart.spec.ts`. The API needs `KWS_RATE_LIMIT=off` for it. README and CLAUDE.md Layout updated. - Accessibility: axe checks for both pages in the mocked suite and in `e2e-idp`; focus moves to the pending status; navigation uses `replace`; an unmount guard (StrictMode-safe) stops state updates after leaving. Not included (agreed): seats, tickets/QR, promo preview, customer cancel, other payment methods. ## Reviews Per-task reviews approved. Whole-branch dual pass: Pass 1 (ponytail) and Pass 2 (correctness, opus). Pass 2's main finding (stale cart after a refusal could allow a second order) is fixed. Pass 1 re-check after the fix rounds: no Must fix. ## Results - `make cover`: **91.3%** (minimum 80%). Go is unchanged, so this is the same figure as on main. - Web: 288 unit tests pass (31 files), typecheck clean, build passes. - `scripts/web-e2e.sh`: 124 passed, 46 skipped (run before the last test-only commit). - `pnpm --filter @kws/ticket e2e:idp`: 7 passed against a local API (rate limit off). Not in CI. ## Known / accepted - No customer cancel: a pending sale just expires at `expires_at`. - Place order is not disabled for unavailable lines; the server's 422 and the line note cover it. - A pending or order page does not flip to "expired" until it re-renders. - A failed background cart refetch after a promo refusal shows the cart error box. - The mocked layout spec does not cover `/checkout` and `/orders/x` (320px / 44px targets). - No unit test for the replace-navigation. - `E2E-FREE` seed is dev-only and has no database guard. ## Not verified Real phones, Safari/Firefox, Zitadel, and the real-IdP journey in CI. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
fix(web): checkout page guard tests (#41)
All checks were successful
ci / changes (pull_request) Successful in 17s
ci / clients (pull_request) Has been skipped
ci / api (pull_request) Has been skipped
ci / web (pull_request) Successful in 5m42s
ci / ci-gate (pull_request) Successful in 7s
cdcc807e60
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
primatekuntech/kws!126
No description provided.