production
This commit is contained in:
@@ -28,6 +28,8 @@ import 'package:miler/views/Dashboard/home/trip.dart';
|
||||
/// says so.
|
||||
/// ─────────────────────────────────────────────────────────────────────────
|
||||
void main() {
|
||||
_adapterCarriesTheStamp();
|
||||
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
setUp(() {
|
||||
@@ -198,7 +200,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('each source says out loud what it is', () {
|
||||
expect(RouteOrderSource.adminSequence.label, 'Hub route');
|
||||
expect(RouteOrderSource.adminSequence.label, 'Assigned route');
|
||||
expect(RouteOrderSource.proximity.label, 'Nearest first');
|
||||
expect(
|
||||
RouteOrderSource.proximity.explanation,
|
||||
@@ -351,3 +353,51 @@ void main() {
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/// ── The adapter has to carry the stamp, or the contract is unreadable ──
|
||||
///
|
||||
/// `RouteOrder` gates on `sequencedat` exactly as the backend specified. That
|
||||
/// is worth nothing if the field never reaches it: `pickupFromBooking` mapped
|
||||
/// `step`, `stoptype`, `etaminutes`, `cumulativekms` and `cumulativeeta` and
|
||||
/// dropped the one that says whether any of them mean anything — so every
|
||||
/// adapted row looked unsequenced and the app fell back to nearest-first on
|
||||
/// routes the hub had solved.
|
||||
void _adapterCarriesTheStamp() {
|
||||
group('the adapter carries sequencedat', () {
|
||||
Map<String, dynamic> booking(Map<String, dynamic> extra) => {
|
||||
'bookingid': 1,
|
||||
'bookingno': 'B1',
|
||||
'pickupaddress': '19 Thadagam Road',
|
||||
...extra,
|
||||
};
|
||||
|
||||
test('a sequenced row arrives sequenced', () {
|
||||
final row = ApiConfig.pickupFromBooking(
|
||||
booking({'step': 2, 'sequencedat': '2026-08-25T09:00:00+05:30'}),
|
||||
);
|
||||
expect(RouteOrder.isSequenced(row), isTrue);
|
||||
expect(RouteOrder.sequenceOf(row), 2);
|
||||
});
|
||||
|
||||
test('step 0 with no stamp is not a route, and that is not a bug', () {
|
||||
// The backend's own words: `step: 0` + `sequencedat: null` means the
|
||||
// rider holds fewer than two active stops, or the stop has no coords.
|
||||
final row = ApiConfig.pickupFromBooking(
|
||||
booking({'step': 0, 'sequencedat': null}),
|
||||
);
|
||||
expect(RouteOrder.isSequenced(row), isFalse);
|
||||
expect(
|
||||
RouteOrder.hasAdminSequence([row]),
|
||||
isFalse,
|
||||
reason: 'nearest-first is the correct answer here, not a fallback bug',
|
||||
);
|
||||
});
|
||||
|
||||
test('an empty stamp is no stamp', () {
|
||||
final row = ApiConfig.pickupFromBooking(
|
||||
booking({'step': 0, 'sequencedat': ' '}),
|
||||
);
|
||||
expect(RouteOrder.isSequenced(row), isFalse);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user