- tags
- #shop
shop-flows: story¶
Each shop flow, run by hand on the sample data (in the Fiddle, nothing is kept). The triggers in Init start the same flows when the data changes for real; a story can't raise those events itself, so it sends the flow's own message.
A new cart: the shop hears who's shopping.
$send shop.cartCreated (id = "cart-3")
▶ Try$expect payload.text is "New cart from Tom Brady-Lee"
▶ Try$expect payload.to is "admins"
▶ TryAn order placed: an invoice, stock reserved from the warehouse that has it, and a thank-you. The half-litre press was down to its reorder point, so it's now low.
$send shop.orderPlaced (id = "o-1004")
▶ Try$expect payload.invoice is "INV-o-1004"
▶ Try$expect payload.total is 58.0
▶ Try$expect payload.reserved[0].reserved is true
▶ Try$expect payload.reserved[0].stock is "low"
▶ TryLow stock, checked on its own: filters are well stocked.
$send shop.checkStock (id = "st-FI-02W-ott")
▶ Try$expect payload is "ok"
▶ TryAbandoned carts: every cart still open after 48 hours is marked abandoned, Omar's from the start of the month among them.
$send shop.abandonedCarts (hours = 48)
▶ Try$expect "cart-1" in payload
▶ TryShipped: the order follows its shipment, and the customer gets the tracking number.
$send shop.shipped (id = "sh-1002")
▶ Try$expect payload.text is "On its way: order o-1002, Purolator PU-55120-88"
▶ TryA return approved: a refund for the filters sent back, and the stock goes back.
$send shop.returnApproved (id = "ret-1")
▶ Try$expect payload.refund is "RF-ret-1"
▶ Try$expect payload.amount is 8.0
▶ Try$expect payload.restocked is 1
▶ Try