Guides · cross-request state
Check that an order stays cancelled after refresh
A customer cancels an order, then reloads and sees it marked pending again. Follow the order across both requests to test that the cancellation survives a refresh.
Does cancellation survive a fresh read?
Run the same actions with independent responses and with a stateful model. In both cases, inspect the order ID and returned state after reopening.
Checkout
Review your items before placing your order.
- Subtotal
- $64.00
- Shipping
- Free
- Order total
- $64.00
Request trace
0 eventsThe next app action starts the trace.
Separate the API state from the client’s view
Dependency state
The configured API model stores the state for the selected resource ID.
Restore its resources and scenario baseline.
Client state
Returned ID · cached data · visible result
Your application decides how the response updates its cache and interface.
Reset client storage, timers and pending work separately.
Create, read, cancel, then read the changed order
Use the actual returned order ID, an authored pending-to-cancelled chart and an explicit repeated-cancel rejection policy. Check resource origin on reads and transition origin on the accepted action; recorded successes can shadow mutable state. The worked example below links to the complete procedure in Docs.
The expected state belongs to that declared test contract. A fixture library alone does not infer lifecycle rules or establish authentication, durable writes or the provider’s business guarantees.
The static response test that falsely passes
Independent successful responses can hide a cancellation that the next read has forgotten. A status-only check passes even if the response still describes a pending order. Check identity and state together, then include the client result: an optimistic interface can conceal stale API state. The worked Docs example includes this counterexample.
Make isolation and cleanup part of the test plan
Plan separate resource instances and separate test contexts, then restore the API baseline and clear client state independently. Reset does not promise stable IDs or restore proxy configuration. Check stale IDs and response origins, and retain the relevant evidence before cleanup. The order-lifecycle procedure covers these steps alongside the case.
Use a simple fixture until the test needs state
- One known trace
- An ordered response queue can be enough. Check the request sequence and the client result, and reset the queue between runs.
- Responses depend on prior actions
- Use a state model when you need alternate paths, repeated reads, out-of-order requests or separate resource instances to affect the response. That model can live in an ordinary test fixture.
- Concurrency or real-system guarantees
- Define the interleaving or conflict you need to test at the relevant system boundary. A mock lifecycle does not establish database transactionality, authentication, durable writes or all of the provider’s business rules.
Connect the model to HTTP only when useful
For a Gostly implementation, use the Pro HTTP workflow. Prepare the create/read inputs and confirm the intended resource and transition paths. Bundled lifecycle behavior and a custom rejection policy are different choices; the statechart setup below explains configuration.
Choose the isolated episode and reset workflow for the case you need. Episode state is tied to the running proxy; plan a fresh baseline after a restart. Optional Team MCP management does not replace the HTTP contract or the client’s assertions.
If you need the local stack, start with the quickstart. If the lifecycle depends on expiry or a scheduled wait, first identify its owner with the clock-control guide.