Skip to content
SDETRole
SDETRole

Write tests that catch the order and invoice bugs

advanced Test design Challenge 22 of 22

The Acme order details page shows the lines of order 2041, a total, and a View invoice link that opens the invoice in a new tab. Its only test checks that the page renders. Four versions have bugs planted in them. Write tests that catch every one, while still passing on the working app.

How the page should behave

Order 2041 contains:

Item Qty Price
Mechanical Keyboard 1 $89.00
Wireless Mouse 2 $35.00
  • Each line is a row with data-testid="order-item", and its Line total cell (data-testid="line-total") is quantity × price.
  • The order total (data-testid="order-total") is the sum of the line totals.
  • View invoice opens /invoices/INV-2041 in a new tab, with the heading “Invoice INV-2041” and a total (data-testid="invoice-total") equal to the order total.

Requirements

  • All your tests pass on the working app.
  • Each buggy version makes at least one of your tests fail.
  • Work out the expected totals from the table above, not from the page.

Expected output

Every test passes on the working app, and each buggy version makes at least one test fail.

Scenarios (5)

Your tests run once against each version of the demo app. They must pass on the working app and fail on every version with a planted bug.

  • ○Working app · must pass
  • ○Bug: line totals ignore quantity · must catch
  • ○Bug: an order line is missing · must catch
  • ○Bug: link opens the wrong invoice · must catch
  • ○Bug: invoice total does not match the order · must catch
example.spec.tsRuns against a live demo app

Ctrl/⌘ + Enter to run tests · your code is saved in this browser

Results

Run the tests to see results here.

Demo app

The working app. You can click around it; your tests start from a fresh copy.

Type to search across SDETRole.

Full-text search by Pagefind · runs in your browser Open search page →