API scenario

Scenario

Fixture Dependency Graph

Build a chain of test fixtures by hand inside a workspace — user, product, payment method, order — and see the specific error each one throws when a dependency is missing, plus a seed-fixtures shortcut once you know the correct order.

How this works

  • · Fixtures have a real dependency graph: a payment method needs its user to already exist; an order needs a user, a product, and a payment method to all exist first.
  • · Creating an order (or a payment method) before its dependency exists fails with a specific named error — user_not_found, product_not_found, payment_method_not_found — so you can tell exactly which link in the chain is missing, not just "bad request."
  • · seed-fixtures is a shortcut that performs the correct build order (user, then payment method, plus an independent product) in a single call — worth using once you understand why that order matters, by hitting the failures yourself first.

What you'll practice

  • An order depends on a user, a product, AND a payment method — the payment method itself depends on the user existing first
  • Creating an order before its dependencies exist fails with a specific, named error (user_not_found / product_not_found / payment_method_not_found), not a generic 400
  • Building fixtures in the wrong order (payment method before its user) fails the same way — order matters
  • seed-fixtures is the shortcut once you understand the graph: one call creates a valid user → payment method → product chain for you
  • This mirrors real test-fixture setup — factories that depend on other factories, and the bugs that show up when that dependency order is assumed rather than enforced

Dependency graph

workspace → user (no deps)

workspace → product (no deps)

workspace + user → payment method

workspace + user + product + payment method → order

Try creating an order first — it fails, naming the first missing dependency:

curl -X POST https://playground.krishanchawla.com/api/scenarios/workspaces/<workspaceId>/orders -H "Content-Type: application/json" -d '{"userId":"nope","productId":"nope","paymentMethodId":"nope"}'

Or skip straight to a working set:

curl -X POST https://playground.krishanchawla.com/api/scenarios/workspaces/<workspaceId>/seed-fixtures

API reference

POST /api/scenarios/workspaces/:workspaceId/users

body { name } → { user } — no dependencies

POST /api/scenarios/workspaces/:workspaceId/products

body { name, price } → { product } — no dependencies

POST /api/scenarios/workspaces/:workspaceId/payment-methods

body { userId, last4 } → { paymentMethod }, or 400 user_not_found if that user doesn't exist yet

POST /api/scenarios/workspaces/:workspaceId/orders

body { userId, productId, paymentMethodId } → { order }, or 400 naming the first missing dependency

POST /api/scenarios/workspaces/:workspaceId/seed-fixtures

no body — shortcut that creates a valid user → payment method → product chain in one call

curl -X POST https://playground.krishanchawla.com/api/scenarios/workspaces/<workspaceId>/orders -H "Content-Type: application/json" -d '{"userId":"nope","productId":"nope","paymentMethodId":"nope"}' # fails first

curl -X POST https://playground.krishanchawla.com/api/scenarios/workspaces/<workspaceId>/seed-fixtures # or skip straight to a working set

  1. 1 Console
Start the scenario