THE QUEEN test
Full order lifecycle E2E test. Serial steps — each depends on the previous one.
Full diagram
No diagram code provided
LegendLiveWaitingCompleted
Reading guide
| Area | States | Primary owner |
|---|---|---|
| Buyer eligibility | name → cpf → phone → email → can_buy | buyer onboarding |
| Seller eligibility | name → birthday → cpf → phone → email → address → payment → can_sell | seller onboarding + Pagar.me |
| Order lifecycle | pending → paid → shipped → delivered → reviewed → settled | checkout + order orchestration |
Buyer eligibility
A user becomes eligible to buy after completing 4 onboarding steps. Validation happens dynamically at checkout via validateBuyerProfile().
No diagram code provided
LegendCompletedClosed / inactive
| # | Step | Field | Route |
|---|---|---|---|
| 1 | Full name | user_profiles.full_name | /setup/name |
| 2 | CPF | user_profiles.cpf | /setup/cpf |
| 3 | Phone | user_profiles.phone | /setup/phone |
| 4 | user_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.
No diagram code provided
LegendCompletedClosed / inactive
| # | Step | Field | Route |
|---|---|---|---|
| 1 | Full name | user_profiles.full_name | /setup/name |
| 2 | Birthday (18+) | user_profiles.birthday | /setup/birthday |
| 3 | CPF | user_profiles.cpf | /setup/cpf |
| 4 | Phone | user_profiles.phone | /setup/phone |
| 5 | user_profiles.email | /setup/email | |
| 6 | Shipping address | user_addresses.* | /setup/address |
| 7 | Payment setup | seller_payment_accounts.seller_id | /setup |
JWT claim: can_sell = CPF ∧ seller_id
Order lifecycle steps
| # | Step | Actor | Assertion |
|---|---|---|---|
| 1 | Checkout with credit card | Buyer | orderId exists, paymentMethod = credit_card |
| 2 | Payment webhook | Pagar.me → System | pending → paid |
| 3 | Seller sees order | Seller | Order visible in pending sales |
| 4 | Seller ships | Seller | Status → shipped |
| 5 | Buyer confirms receipt | Buyer | Status → delivered, funds released |
| 6 | Buyer leaves review | Buyer | 201 response, review created |
| 7 | Seller checks wallet | Seller | Balance available with R$ value |
Boundaries
| Concern | Location | Why |
|---|---|---|
| Buyer validation | ensure-buyer-profile.action.ts | Checked dynamically at checkout, no JWT flag |
| Seller payment account creation | ensure-seller-payment-account.action.ts | Registers the seller with the market's provider on onboarding completion |
JWT can_sell claim | custom_access_token_hook.sql | Set on every token refresh based on DB state |
| Order state transitions | checkout + order orchestration | pending onward is commerce flow |
Source
apps/web/e2e/the-queen.spec.ts