kiwi/tests/api
pyr0ball 17e62c451f feat: visual label capture for unenriched barcodes (kiwi#79)
When a barcode scan finds no product in FDC/OFF, paid-tier users now see a
"Capture label" offer instead of a dead-end "add manually" prompt.

Backend:
- Migration 036: captured_products local cache table (keyed by barcode,
  UPSERT on conflict so re-capture refreshes rather than errors)
- store.get_captured_product / save_captured_product (with JSON decode for
  ingredient_names and allergens)
- app/services/label_capture.py: wraps cf-core VisionRouter (caption API);
  graceful fallback to zero-confidence mock when stub/error; JSON fence
  stripping; confidence clamped to [0,1]; KIWI_LABEL_CAPTURE_MOCK=1 for tests
- New schemas: LabelCaptureResponse, LabelConfirmRequest, LabelConfirmResponse
- POST /inventory/scan/label-capture — image to extraction (paid+ gate, 403)
- POST /inventory/scan/label-confirm — save confirmed product + optional
  inventory add
- Both scan endpoints now: check captured_products cache before FDC/OFF;
  set needs_visual_capture=True for gap products on paid tier; BarcodeScanResult
  gains needs_visual_capture field
- visual_label_capture feature gate added to tiers.py (paid)

Tests: 42 new tests (service, store/migration, API endpoints) — 367 total passing

Frontend:
- InventoryList.vue: capturePhase state machine (offer => uploading => reviewing)
- Offer card appears after scan gap (calm UX: no urgency, Discard always visible)
- Review form: pre-populated from extraction; amber label highlights for
  unread fields (confidence < 0.7); comma-separated ingredients/allergens
- api.ts: LabelCaptureResult + LabelConfirmRequest types; captureLabelPhoto()
  and confirmLabelCapture() API methods
2026-04-24 17:57:25 -07:00
..
__init__.py feat: recipe + staple API endpoints with tier gating 2026-03-31 12:49:38 -07:00
test_browse_time_effort.py feat: time & effort signals — active/passive split, effort cards, annotated steps (kiwi#50) 2026-04-24 09:29:54 -07:00
test_community_endpoints.py chore: commit in-progress work -- tag inferrer, imitate endpoint, hall-of-chaos easter egg, migration files, Dockerfile .env defense 2026-04-14 13:23:15 -07:00
test_feedback.py feat: migrate feedback endpoint to circuitforge-core router 2026-04-05 17:57:36 -07:00
test_label_capture.py feat: visual label capture for unenriched barcodes (kiwi#79) 2026-04-24 17:57:25 -07:00
test_meal_plans.py fix(meal-planner): validate meal_type path param, enforce store whitelist safety, add week_start date validation, make PrepTask frozen 2026-04-12 13:51:50 -07:00
test_orch_budget_in_recipes.py feat(kiwi): gate L3/L4 recipes behind orch budget check; fallback to L2 on exhaustion 2026-04-14 15:24:57 -07:00
test_orch_usage.py feat(kiwi): add /orch-usage proxy endpoint for frontend budget display 2026-04-14 15:42:58 -07:00
test_recipe_build_endpoints.py fix(tests): correct build endpoint test fixture 2026-04-14 14:57:16 -07:00
test_recipes.py feat: recipe + staple API endpoints with tier gating 2026-03-31 12:49:38 -07:00
test_settings.py feat: time-first recipe entry (kiwi#52) 2026-04-24 10:15:58 -07:00
test_stream_token.py feat(streaming): add POST /recipes/stream-token endpoint 2026-04-24 10:22:30 -07:00