Acceptance Test the Shopping Cart (Part II)

Let's look at another scenario to cross-check our cart's functionality.

We'll cover the following

Multi-server testing

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

  1. Start two servers, application and back-end, in a freshly seeded state.
  2. Release both shoes from the back-end server.
  3. Load the webpage.
  4. Add size 6 of the top shoe, remove it, and add it again.
  5. Open a second tab of your webpage.
  6. Add a second shoe to the cart from the second tab.
  7. Run the inventory reducer script from the back-end server.
  8. Check both tabs’ cart displays once the items are sold out.
  9. Remove all shoes from your cart.
  10. Try to add a sold-out shoe to your cart.

Write expectations for the test

  1. The shopper sees the size selectors after step 3.
  2. The shopper sees one item in their cart after step 4.
  3. The shopper sees that both tabs show one shoe in the cart after step 5.
  4. The shopper sees that both tabs show two shoes in the cart after step 6.
  5. The inventory reducer script runs without error.
  6. The shopper sees that all items in their cart are grayed out.
  7. The shopper can remove all items from their cart.
  8. 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.

Get hands-on with 1000+ tech skills courses.