---
name: md-e2e-discipline
description: Use when authoring Multideal E2E tests, fixtures, Playwright configuration, or setup involving users, vendors, deals, purchases, reviews, or payments.
---

# Multideal E2E Discipline

Audience: AI coding agents first.

Own deterministic setup, isolation, and authoritative oracles. Journey derivation lives in `creating-journey-e2e-tests`; execution lives in project `md-e2e`.

## Factory-only business setup

Tests MUST create business entities through factory verbs or direct real APIs.

| Entity | Required path |
|---|---|
| User | `account.createUser` |
| Vendor | `vendorRegister` → `onboardVendor` → `vendorActivate` |
| Deal | `uploadDeal` → `dealApprove` |
| Purchase | `addToCart` → checkout → finalize |
| Review | `postReview` |

Raw SQL/ORM mutation of users, vendors, deals, purchases, reviews, payments, vouchers, inventory, or ledgers is forbidden.

Exceptions:

- Taxonomy bootstrap before suite.
- Explicit database-trigger regression test proving mutation is rejected.

DB reads are allowed for exact authoritative assertions.

## Payment preconditions

Checkout, purchase, settlement, or payout tests require a vendor onboarded through real Stripe IL transfers-only flow. Never fabricate provider account state.

## Isolation

- Unique actor and mutable entity IDs per test.
- Shared fixtures immutable after creation.
- No discovery of arbitrary live entities for correctness tests.
- No cross-test ordering dependency.
- Cleanup is idempotent and scoped to test-owned records.
- Parallel-safe unless manifest explicitly marks serial external dependency.

## Trigger integrity

Factories establish preconditions only. Test MUST drive behavior under test through real UI/API trigger. Never factory-create terminal state for happy-path test.

## Oracle integrity

- Use exact schema status values.
- Assert ownership, amounts, currency, quantities, and state transitions.
- Failure tests compare before/after projections for forbidden effects.
- API authorization status derives from route source, not URL naming convention.

## Waits and selectors

- Prefer role, label, and scoped `data-testid`.
- Never use DOM ordinal selectors without scoped stable parent.
- Wait for observable state or exact response; never `networkidle`.
- Never hide product failure behind conditional action, retry loop, `skip`, or `fixme`.

## Before done

- [ ] Factory/API setup only.
- [ ] Required vendor onboarding complete.
- [ ] Mutable state unique and parallel-safe.
- [ ] Real trigger remains inside test.
- [ ] DB used only for reads or documented exception.
- [ ] Exact authoritative oracles and forbidden-effect projections exist.
