Files
canteen-asset-tracker/tests/frontend
shawn b20998e8e3 fix: OCR last-5-digits extraction, barcode 1D-only scanning, auto-checkin on create
- OCR: Extract only last 5 digits from Connect ID (XXXXX-XXXXXX → last 5)
- Barcode: Switch to decodeFromVideoDevice with 1D-only format hints
  (Code 128/39/EAN/UPC/ITF/Codabar), TRY_HARDER, 50ms scan interval
- Auto check-in: New assets auto-checkin with GPS on creation via
  all three entry modes (barcode, OCR, manual)
- Tests: Updated e2e tests for login wait and API flow
2026-05-20 15:03:20 -04:00
..

Frontend E2E Tests

Playwright tests for the Canteen Asset Tracker SPA.

Requirements

  • System Chromium installed (/usr/bin/chromium-browser)
  • Playwright Python: pip install playwright
  • All backend deps: pip install -r requirements.txt

Running

cd ~/projects/canteen-asset-tracker
python3 -m pytest tests/frontend/ -v

Architecture

  • Each test gets an isolated temp SQLite database
  • A FastAPI server runs on a random port in a background thread
  • CANTEEN_SKIP_AUTH=1 skips auth middleware so Playwright doesn't need real tokens
  • Playwright launches system Chromium in headless mode at iPhone 14 viewport size
  • Geolocation is mocked to Orlando, FL

Writing Tests

Import the page and live_server fixtures:

def test_something(page, live_server):
    page.locator("#someButton").click()
    assert page.locator(".result").is_visible()