🧪 Test Hub
testing: Demo target v3.0.0 · built-in demo site

DEMO-011 Freight: quote with a promo code

Edit Load test Duplicate

Walks the four-step quote wizard, applies promo code SPRING10, checks the discount is exactly 10% of the subtotal, books the shipment and tracks the booking.

demoformsfreightmoney version: 1.0 DEMO-011__freight_quote_with_promo.py group: Freight regressiongroup: Freight smokegroup: Python and TypeScript, side by side

Runs
16
Pass rate
88%
14 passed / 2 failed
Avg duration
3s
p95 3s
Estimate
3s
avg of last 10 judged runs
Flakiness
0.27
0 stable · 1 alternates
Current streak
9
passed

Last 16 results newest on the right — click a square to open that run

Duration per run point color = outcome; dashed = 7-run average; click a point to open the run

Step timing trends the same step compared across the last 16 runs — slowest steps first, one line each

How long it takes distribution of 16 runs — two humps mean two different behaviours hiding behind one average

fastest 2s · slowest 4s

Why this test failed grouped by message, last 90 days

timesmessagelast
2 AssertionError: SPRING10 should take 10% off the $117.62 subtotal ($1… Sep 24 open

Outcomes by target version

What this test does plain language, derived from the code

  1. response = page.goto(ctx.base_url + "freight/quote/?restart=1")
  2. assert response.ok, f"the quote page answered HTTP {response.status}: {page.title()!r}"
  3. ⏱ Timed phase: route
  4. Type “San Francisco” into the “From (city)” field
  5. Type “San Diego” into the “To (city)” field
  6. Click the button labelled “Next: cargo”
  7. ⏱ Timed phase: cargo
  8. Type “120” into the “Total weight (kg)” field
  9. Type “3” into the “Pieces” field
  10. Click the button labelled “Next”
  11. ⏱ Timed phase: choose a service
  12. page.get_by_role("radio", name="Standard").check()
  13. Click the button labelled “Next: review”
  14. ⏱ Timed phase: apply promo SPRING10
  15. Type “SPRING10” into the “Promo code” field
  16. Click the button labelled “Apply”
  17. Wait until #price-discount appears
  18. amount = lambda sel: float(page.get_attribute(sel, "data-amount")) # noqa: E731
  19. subtotal, discount = amount("#price-subtotal"), amount("#price-discount")
  20. fuel, total = amount("#price-fuel"), amount("#price-total")
  21. ctx.log(f"subtotal ${subtotal:.2f}, discount ${discount:.2f}, total ${total:.2f}")
  22. Take a screenshot (“priced”)
  23. expected = round(subtotal * 0.10, 2)
  24. assert abs(discount - expected) < 0.011, (
  25. f"SPRING10 should take 10% off the ${subtotal:.2f} subtotal (${expected:.2f}), "
  26. f"but the quote takes ${discount:.2f} off")
  27. assert abs(total - (subtotal - discount + fuel)) < 0.011, (
  28. f"the total ${total:.2f} is not subtotal - discount + fuel surcharge")
  29. ⏱ Timed phase: book
  30. Type “Grace Hopper” into the “Contact name” field
  31. Type “grace@example.gov” into the “Email” field
  32. Click the button labelled “Book shipment”
  33. Wait until #booking-id appears
  34. booking = page.inner_text("#booking-id")
  35. ctx.log(f"booked {booking}")
  36. ⏱ Timed phase: track the new booking
  37. Click the link labelled “Track this shipment”
  38. Wait until #track-result appears
  39. assert page.inner_text("#track-status") == "Booked"
  40. assert booking in page.inner_text("#track-result")
Show the code
"""A four-step quote, a promo code, a booking -- and checking the money.

Walks the quote wizard the way a customer does (route, cargo, service,
review), applies promo code SPRING10 and checks the discount is exactly 10%
of the subtotal -- computed from the numbers ON THE PAGE, so the test stays
right when prices change. Then it books the shipment and tracks the new
booking number.

Written in the "user-facing locators" style (get_by_label, get_by_role):
it reads like the steps a person follows, and it is what the Remote
Recorder produces too.
"""


def run(page, ctx):
    response = page.goto(ctx.base_url + "freight/quote/?restart=1")
    assert response.ok, f"the quote page answered HTTP {response.status}: {page.title()!r}"

    with ctx.timed("route"):
        page.get_by_label("From (city)").fill("San Francisco")
        page.get_by_label("To (city)").fill("San Diego")
        page.get_by_role("button", name="Next: cargo").click()

    with ctx.timed("cargo"):
        page.get_by_label("Total weight (kg)").fill("120")
        page.get_by_label("Pieces").fill("3")
        page.get_by_role("button", name="Next").click()

    with ctx.timed("choose a service"):
        page.get_by_role("radio", name="Standard").check()
        page.get_by_role("button", name="Next: review").click()

    with ctx.timed("apply promo SPRING10"):
        page.get_by_label("Promo code").fill("SPRING10")
        page.get_by_role("button", name="Apply").click()
        page.wait_for_selector("#price-discount")

    amount = lambda sel: float(page.get_attribute(sel, "data-amount"))  # noqa: E731
    subtotal, discount = amount("#price-subtotal"), amount("#price-discount")
    fuel, total = amount("#price-fuel"), amount("#price-total")
    ctx.log(f"subtotal ${subtotal:.2f}, discount ${discount:.2f}, total ${total:.2f}")
    ctx.screenshot("priced")

    expected = round(subtotal * 0.10, 2)
    assert abs(discount - expected) < 0.011, (
        f"SPRING10 should take 10% off the ${subtotal:.2f} subtotal (${expected:.2f}), "
        f"but the quote takes ${discount:.2f} off")
    assert abs(total - (subtotal - discount + fuel)) < 0.011, (
        f"the total ${total:.2f} is not subtotal - discount + fuel surcharge")

    with ctx.timed("book"):
        page.get_by_label("Contact name").fill("Grace Hopper")
        page.get_by_label("Email").fill("grace@example.gov")
        page.get_by_role("button", name="Book shipment").click()
        page.wait_for_selector("#booking-id")
    booking = page.inner_text("#booking-id")
    ctx.log(f"booked {booking}")

    with ctx.timed("track the new booking"):
        page.get_by_role("link", name="Track this shipment").click()
        page.wait_for_selector("#track-result")
    assert page.inner_text("#track-status") == "Booked"
    assert booking in page.inner_text("#track-result")

All runs

RunStatusQueuedDuration VersionTriggerBatch
#486 passed 2026-09-25 07:00:10 3s 3.0.0 schedule schedule: Freight regression …
#470 passed 2026-09-25 00:30:11 2s 3.0.0 group group: Python and TypeScript,…
#393 passed 2026-09-24 23:24:12 2s 3.0.0 group group: Freight smoke
#389 passed 2026-09-24 23:23:58 2s 3.0.0 group group: Freight smoke
#385 passed 2026-09-24 23:22:20 2s 3.0.0 group group: Freight smoke
#381 passed 2026-09-24 23:10:27 2s 3.0.0 group group: Freight smoke
#374 passed 2026-09-24 22:10:14 3s 3.0.0 schedule schedule: Freight smoke 22:10
#366 passed 2026-09-24 22:05:21 4s 3.0.0 group group: Freight regression
#356 passed 2026-09-24 22:04:30 3s 3.0.0 group group: Freight smoke
#352 failed 2026-09-24 22:04:21 3s 2.1.0 group group: Freight smoke
#332 passed 2026-09-24 19:48:13 3s 3.0.0 cli-adopted 4 tests (terminal)
#308 passed 2026-09-24 18:59:58 3s 3.0.0 cli-adopted 8 tests (terminal)
#300 failed 2026-09-24 18:57:59 2s 2.1.0 cli-adopted 8 tests (terminal)
#288 passed 2026-09-24 18:55:40 3s 2.0.0 cli-adopted 8 tests (terminal)
#149 passed 2026-09-24 18:52:00 3s 1.1.0 cli-adopted 8 tests (terminal)
#11 passed 2026-09-24 18:48:19 3s 1.0.0 cli-adopted 8 tests (terminal)