Spec S-0042 · v1 · DRAFT
Discount coupons in the checkout
3 requirements · 6 criteria · 5 tasks (supabase-db, backend-api, frontend-nextjs, qa-tests, reviewer)
▶Requirements and criteria
R1Coupons live in the database and only the server reads them.
R1.1npx supabase db reset applies the cupones migration without errors
R1.2npm test -- tests/db/cupones-rls.test.ts passes: an anonymous user cannot read cupones
R2The checkout validates the coupon on the server.
R2.1npm test -- tests/api/cupones-validar.test.ts passes: expired coupon → 422, valid coupon → 200 with the discount
R2.2npx tsc --noEmit with no errors
R3The buyer sees the discount before paying.
R3.1Chrome smoke test: with coupon ACME10, the total drops 10% and the “Discount” line appears
R3.2Smoke test at 390 px: the coupon field fits without horizontal scroll
▶Task plan
T1supabase-dbCoupons table, migration and RLS
R1.1, R1.2
T2backend-apiEndpoint POST /api/cupones/validar
R2.1, R2.2 · depends on T1
T3frontend-nextjsCoupon field and discount line in the checkout
R3.1, R3.2 · depends on T2
T4qa-testsVerification against the criteria, desktop and 390 px
R1.1, R1.2, R2.1, R2.2, R3.1, R3.2 · depends on T3
T5reviewerDiff review: server-side validation and RLS
R1.2, R2.1 · depends on T3



