import 'package:flutter_test/flutter_test.dart'; import 'package:rippr/src/domain/activity_profile.dart'; import 'package:rippr/src/domain/models.dart'; import 'package:rippr/src/telemetry/telemetry.dart'; /// Ported concept check for V3-01: activity type must drive real behaviour, not just a /// label. void main() { test( 'the motorcycle profile reproduces the constants the app shipped with before ' 'activity type existed', () { // ActivityProfile.motorcycle deliberately duplicates these as literals rather than // importing them, to avoid a domain-layer dependency cycle -- this is the promised // check that the two never drift apart silently. expect(ActivityProfile.motorcycle.noiseFloorKmh, speedNoiseFloorKmh); expect(ActivityProfile.motorcycle.elevationThresholdM, 3.0); expect(ActivityProfile.motorcycle.elevationWindowSamples, 15); expect(ActivityProfile.motorcycle.accuracyGateM, 50.0); expect(ActivityProfile.motorcycle.histogramBucketKmh, 10); }, ); test('forActivity covers every Activity value with no fallback surprises', () { for (final activity in Activity.values) { // Must not throw -- an unhandled case here would be a runtime crash on a // brand-new trip, not a compile error, since the switch is exhaustive over the // enum today but a future Activity value could slip through review. expect(() => ActivityProfile.forActivity(activity), returnsNormally); } }); test('slower activities get a lower noise floor than a motorcycle', () { final motorcycle = ActivityProfile.forActivity(Activity.motorcycle); final walking = ActivityProfile.forActivity(Activity.walking); final running = ActivityProfile.forActivity(Activity.running); expect(walking.noiseFloorKmh, lessThan(motorcycle.noiseFloorKmh)); expect(running.noiseFloorKmh, lessThan(motorcycle.noiseFloorKmh)); expect( walking.noiseFloorKmh, lessThan(running.noiseFloorKmh), reason: 'a walk is slower than a run, so real movement sits even closer to noise', ); }); test('running and walking use a finer speed histogram than a motorcycle', () { // 10 km/h bands are useless for an activity that rarely exceeds 10 km/h at all. expect(ActivityProfile.forActivity(Activity.running).histogramBucketKmh, 1); expect(ActivityProfile.forActivity(Activity.walking).histogramBucketKmh, 1); expect(ActivityProfile.forActivity(Activity.motorcycle).histogramBucketKmh, 10); }); test('scooter and other fall back to the safest generic profile', () { expect( ActivityProfile.forActivity(Activity.scooter), same(ActivityProfile.motorcycle), ); expect( ActivityProfile.forActivity(Activity.other), same(ActivityProfile.motorcycle), ); }); }