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-2041in 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
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.
Related interview questions
- Explain Browser, BrowserContext and Page in Playwright. Why do contexts matter for test isolation?
- How do Playwright fixtures work? Build a custom fixture with test.extend.
- How do you mock or modify network responses in Playwright, and when should you?
- What is your locator strategy in Playwright, and why prefer getByRole?