Skip to content

feat(app): staged mock sensor scenario harness for OG_DEMO - #8

Open
shroominic wants to merge 1 commit into
feat/sim-demo-modefrom
feat/mock-sensor-scenarios
Open

feat(app): staged mock sensor scenario harness for OG_DEMO#8
shroominic wants to merge 1 commit into
feat/sim-demo-modefrom
feat/mock-sensor-scenarios

Conversation

@shroominic

Copy link
Copy Markdown
Owner

Staged mock sensor harness

A switchable scenario system so the fleet (and the founder) can test every sensor scenario in the iOS simulator without real BLE. This is the testing backbone for the sensor-lifecycle / alert features.

Stacked on #4 / OG_DEMO — this branch builds on feat/sim-demo-mode so the native demo driver is available. It rebases to main after #4 merges. The diff here is intentionally scoped to the scenario harness only.

What's in it

Extends the existing DemoCgmDriver into a scenario-driven mock. A new pure, clock-injectable MockScenarioCatalog maps each MockScenario to a fully-formed CgmSessionSnapshot so the dashboard renders that exact state.

Scenarios: warmup, activeNormal, activeHigh (sustained high — trips high alert), activeLow (sustained low — trips low alert), rapidRise, rapidFall, expiringSoon (hours left on the 15-day life), expired (offboarding / session stopped), signalLoss, disconnected, multiSensorHistory (previous + current sensor), error.

How to switch scenarios

  1. Initial scenario via dart-define: flutter run --dart-define=OG_DEMO=true --dart-define=OG_SCENARIO=activeHigh
  2. At runtime, no rebuild: open Settings (tune icon) → Developer tab → Mock scenario picker. Swaps the live scenario instantly via the existing snapshot stream.

Both paths are gated behind OG_DEMO; production builds are untouched (default scenario is activeNormal, preserving the original demo behavior).

Verification (iPhone 15 simulator)

  • flutter analyze clean (only the one pre-existing live_activity_payload.dart info from the base branch).
  • flutter test — all 36 tests pass, including new mock_scenarios_test.dart (scenario→snapshot mapping + live switching) and a widget test driving the Developer-tab picker end to end.
  • Screenshots of 3 distinct scenarios on the simulator:
    • warmup/tmp/og-mock-warmup.png ("40 min — Warming up", empty history)
    • activeHigh/tmp/og-mock-activeHigh.png (234 mg/dL, history riding the high band)
    • expired/tmp/og-mock-expired.png ("Sensor expired", readings frozen 2h ago)

🤖 Generated with Claude Code

Extend the OG_DEMO demo driver into a scenario-driven mock so the whole
sensor lifecycle and alert surface can be exercised in the iOS simulator
without real BLE.

- Add MockScenarioCatalog (mock_scenarios.dart): pure, clock-injectable
  mapping from MockScenario -> CgmSessionSnapshot for warmup, activeNormal,
  activeHigh, activeLow, rapidRise, rapidFall, expiringSoon, expired,
  signalLoss, disconnected, multiSensorHistory, and error.
- Make DemoCgmDriver/DemoCgmSession scenario-driven with a live
  applyScenario() switch; default stays activeNormal so existing demo
  behavior is unchanged.
- Select the initial scenario via --dart-define=OG_SCENARIO=<name> and
  switch at runtime from a new "Mock scenario" picker in the Developer
  settings tab. Both paths gated behind OG_DEMO; production untouched.
- Tests: scenario->snapshot mapping, live scenario switching, and a widget
  test driving the Developer-tab picker end to end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant