Merge FB-07: fix Route Planner opening on Null Island

# Conflicts:
#	docs/feedback/FB-07-route-planner-null-island.md
This commit is contained in:
2026-08-25 00:15:10 -05:00
3 changed files with 141 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:rippr/src/app/providers.dart';
import 'package:rippr/src/data/database.dart';
import 'package:rippr/src/data/route_plan_repository.dart';
import 'package:rippr/src/recording/location_source.dart' show LocationFix;
import 'package:rippr/src/ui/app_shell.dart';
import 'package:rippr/src/ui/components/floating_pill.dart';
import 'package:rippr/src/ui/components/ride_map.dart' show ambientZoom;
@@ -30,8 +31,8 @@ void main() {
tearDown(() async => db.close());
Widget host(Widget child) => ProviderScope(
overrides: [databaseProvider.overrideWithValue(db)],
Widget host(Widget child, {List<Override> overrides = const []}) => ProviderScope(
overrides: [databaseProvider.overrideWithValue(db), ...overrides],
child: MaterialApp(theme: ripprTheme(), home: child),
);
@@ -227,6 +228,79 @@ void main() {
expect(map.options.initialZoom, ambientZoom);
});
screenTest('a brand-new route opens centered on the rider\'s real location, '
'not Null Island (FB-07)', (tester) async {
const fix = LocationFix(
timestamp: 1000,
latitude: 51.05,
longitude: -114.07,
speedMps: 0,
altitudeM: 0,
accuracyM: 5,
bearingDeg: 0,
);
final id = await repo.createRoutePlan(1000);
await pumpMap(
tester,
host(
RoutePlannerScreen(routeId: id),
overrides: [
ambientPositionProvider.overrideWith((ref) => Stream.value(fix)),
],
),
);
final map = tester.widget<FlutterMap>(find.byType(FlutterMap));
expect(map.options.initialCenter.latitude, closeTo(51.05, 1e-9));
expect(map.options.initialCenter.longitude, closeTo(-114.07, 1e-9));
});
screenTest('a brand-new route falls back to (0, 0) when no ambient fix is '
'available (FB-07)', (tester) async {
final id = await repo.createRoutePlan(1000);
await pumpMap(
tester,
host(
RoutePlannerScreen(routeId: id),
overrides: [
ambientPositionProvider.overrideWith((ref) => Stream.value(null)),
],
),
);
final map = tester.widget<FlutterMap>(find.byType(FlutterMap));
expect(map.options.initialCenter.latitude, 0);
expect(map.options.initialCenter.longitude, 0);
});
screenTest('a route with a real waypoint still centers on the pin, not the '
'ambient position (FB-07)', (tester) async {
const fix = LocationFix(
timestamp: 1000,
latitude: 51.05,
longitude: -114.07,
speedMps: 0,
altitudeM: 0,
accuracyM: 5,
bearingDeg: 0,
);
final id = await repo.createRoutePlan(1000);
await repo.addWaypoint(id, 51.0, -114.0);
await pumpMap(
tester,
host(
RoutePlannerScreen(routeId: id),
overrides: [
ambientPositionProvider.overrideWith((ref) => Stream.value(fix)),
],
),
);
final map = tester.widget<FlutterMap>(find.byType(FlutterMap));
expect(map.options.initialCenter.latitude, closeTo(51.0, 1e-9));
expect(map.options.initialCenter.longitude, closeTo(-114.0, 1e-9));
});
screenTest('the offline-tiles download menu item is disabled with no pins '
'(V3-11, UI-06: now a PopupMenuItem behind the overflow menu)',
(tester) async {