Side Effect
A user is only previewing a price. Do not silently write an order or send email; do that only after explicit submission.
A user is only previewing a price. Do not silently write an order or send email; do that only after explicit submission.
A preview unexpectedly writes data and sends mail.
Problem and key mechanism: The user only wants a shipping and total preview, but the old endpoint writes a quote and sends email; separate preview calculation from explicit submission so Confirm order alone saves and notifies.
How to observe the improvement: Save the order, decrement stock, or send notifications only after explicit confirmation, and return the real status of each action. Verify that preview adds no record or email, while one confirmed submission creates the expected record and notification once.
A second scenario: content publishing: Previewing an article should not publish the draft or notify subscribers. Those external changes should wait for an explicit Publish action, with the publication state and notification result checked separately.
Separate quote preview from order submission: preview should calculate and return the price without writing a quote or sending email; only an explicit Confirm order should save and notify once. Add tests proving preview adds no record or email and one submission creates the expected external effects once.