THE QUEEN test

Full order lifecycle E2E test. Serial steps — each depends on the previous one.

Full diagram

LegendLiveWaitingCompleted

Reading guide

AreaStatesPrimary owner
Buyer eligibilitynamecpfphoneemailcan_buybuyer onboarding
Seller eligibilitynamebirthdaycpfphoneemailaddresspaymentcan_sellseller onboarding + Pagar.me
Order lifecyclependingpaidshippeddeliveredreviewedsettledcheckout + order orchestration

Buyer eligibility

A user becomes eligible to buy after completing 4 onboarding steps. Validation happens dynamically at checkout via validateBuyerProfile().

LegendCompletedClosed / inactive
#StepFieldRoute
1Full nameuser_profiles.full_name/setup/name
2CPFuser_profiles.cpf/setup/cpf
3Phoneuser_profiles.phone/setup/phone
4Emailuser_profiles.email/setup/email

No can_buy JWT flag — buyer eligibility is validated per-transaction at checkout.

Seller eligibility

A user becomes eligible to sell after completing 7 onboarding steps. The can_sell JWT claim is set by custom_access_token_hook when CPF + recipient ID are present.

LegendCompletedClosed / inactive
#StepFieldRoute
1Full nameuser_profiles.full_name/setup/name
2Birthday (18+)user_profiles.birthday/setup/birthday
3CPFuser_profiles.cpf/setup/cpf
4Phoneuser_profiles.phone/setup/phone
5Emailuser_profiles.email/setup/email
6Shipping addressuser_addresses.*/setup/address
7Payment setupseller_payment_accounts.seller_id/setup

JWT claim: can_sell = CPF ∧ seller_id

Order lifecycle steps

#StepActorAssertion
1Checkout with credit cardBuyerorderId exists, paymentMethod = credit_card
2Payment webhookPagar.me → Systempending → paid
3Seller sees orderSellerOrder visible in pending sales
4Seller shipsSellerStatus → shipped
5Buyer confirms receiptBuyerStatus → delivered, funds released
6Buyer leaves reviewBuyer201 response, review created
7Seller checks walletSellerBalance available with R$ value

Boundaries

ConcernLocationWhy
Buyer validationensure-buyer-profile.action.tsChecked dynamically at checkout, no JWT flag
Seller payment account creationensure-seller-payment-account.action.tsRegisters the seller with the market's provider on onboarding completion
JWT can_sell claimcustom_access_token_hook.sqlSet on every token refresh based on DB state
Order state transitionscheckout + order orchestrationpending onward is commerce flow

Source

apps/web/e2e/the-queen.spec.ts

On this page