Acceptance Test the Shopping Cart (Part II)
This scenario will ensure that some of the more complex features of our shopping cart work as expected. We haven’t yet tested how our cart works in a multi-server setup, so we’ll perform this scenario across two servers to ensure that it does work.
Define the test
A shopper is connected to the store and sees that the shoes have already been released. The shopper adds a shoe to their cart, removes it, and adds it again. The shopper opens a second tab and adds another shoe to their cart from the second tab. The shoes sell out from a second server. The shopper sees that their items are sold out, and they remove the items from their cart.
Write steps for the test
- Start two servers, application and back-end, in a freshly seeded state.
- Release both shoes from the back-end server.
- Load the webpage.
- Add size 6 of the top shoe, remove it, and add it again.
- Open a second tab of your webpage.
- Add a second shoe to the cart from the second tab.
- Run the inventory reducer script from the back-end server.
- Check both tabs’ cart displays once the items are sold out.
- Remove all shoes from your cart.
- Try to add a sold-out shoe to your cart.
Write expectations for the test
- The shopper sees the size selectors after step 3.
- The shopper sees one item in their cart after step 4.
- The shopper sees that both tabs show one shoe in the cart after step 5.
- The shopper sees that both tabs show two shoes in the cart after step 6.
- The inventory reducer script runs without error.
- The shopper sees that all items in their cart are grayed out.
- The shopper can remove all items from their cart.
- The shopper cannot add sold-out shoes to their cart.
Let’s use the following instructions to execute the test. We’ll start multiple servers, and we will run Elixir functions only on the back-end server.