Files
doormile_milderapp/test/stop_map_contract_test.dart
Thiru-tenext d7348e253f Miler rider app: surface system, visible design language, backend lifecycle
Design system
- MilerSurface ladder (canvas → working → raised → floating) with MilerPanel
  as layer 1; canvas moved to #DEE3EA so white separates at 1.290:1.
- Visible vocabulary applied across Home, Deliveries, Activity, Account and
  the sheets: hero heads (tabular numeral + small caption, clamped at 1.3x),
  canvas wells for anything that opens, small filled tags for shelf labels,
  demoted placeholders. Recorded in DESIGN_SYSTEM.md §6.
- One icon family: 222 Material glyphs migrated to Lucide; none left outside
  lib/xpress.
- Colour semantics corrected: amber only for what is genuinely owed, brand red
  reserved for the live stop, disabled primaries go neutral rather than pale.

Data and lifecycle
- lib/data/lifecycle.dart reads mutations for what they prove; route_order.dart
  makes admin sequence the single ordering authority; service_day.dart, and
  stop_area.dart rewritten against live Coimbatore addresses (digit-token
  stripping, city stoplist, street suffixes, stammer collapse).
- countLabel states the load once, in bags.

Testing
- 1440 tests passing; golden shot harnesses for Home, Deliveries, Activity,
  sheets and verify, with test/failures/ now gitignored (diff debris).
- New pins: home_gutter_test, stop_area_test, plus updated structural bounds.

Note: this commit also carries pre-existing working-tree deletions that were
present before this work (API_SPEC.md, README.md, demo test fixtures).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-22 05:40:35 +05:30

98 lines
3.9 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:miler/data/service_profile.dart';
import 'package:miler/data/stop_contact.dart';
/// ─────────────────────────────────────────────────────────────────────────
/// THE LIVE STOP SCREEN'S CONTRACT
///
/// One screen serves both legs — a kitchen counter and a customer's door — and
/// almost everything on it changes meaning between them: the destination, the
/// copy, the action, and the number under the Call button.
///
/// That last one is the dangerous one, because it fails silently. A rider at a
/// door taps Call, reaches the kitchen, and the screen looks correct
/// throughout. These pin who is being rung, per leg, and who the app *says* is
/// being rung — the two used to be decided in different places.
/// ─────────────────────────────────────────────────────────────────────────
void main() {
tearDown(() => ServiceProfile.setActive(ServiceProfile.parcel));
group('the contact belongs to the leg', () {
test('a delivery prefers the drop contact when one exists', () {
final contact = StopContact.forLeg(const {
'pickupcontactno': '9000000001',
'dropcontactno': '9000000002',
}, delivery: true);
expect(contact.number, '9000000002');
expect(contact.who, 'the customer');
expect(contact.action, 'Call the customer');
});
test('a pickup prefers the pickup contact', () {
final contact = StopContact.forLeg(const {
'pickupcontactno': '9000000001',
'dropcontactno': '9000000002',
}, delivery: false);
expect(contact.number, '9000000001');
expect(contact.who, 'the pickup');
expect(contact.action, 'Call the pickup');
});
test("today's payload carries one number, and both legs reach it", () {
// Verified against production 21 Aug 2026: `GET /miler/bookings` returns
// exactly one phone field, `customerphone`, which the adapter stores as
// `pickupcontactno`. There is no drop contact in the contract at all.
//
// So the number is the same on both legs and dialling it is correct
// either way — the defect was never the digits, it was the app calling
// it "the customer" while the rider stood at a kitchen counter.
const live = {'pickupcontactno': '9787698259'};
expect(StopContact.forLeg(live, delivery: true).number, '9787698259');
expect(StopContact.forLeg(live, delivery: false).number, '9787698259');
expect(
StopContact.forLeg(live, delivery: true).who,
isNot(StopContact.forLeg(live, delivery: false).who),
reason: 'the label still has to tell the rider who answers',
);
});
test('no number means no control, not a dead one', () {
final contact = StopContact.forLeg(const {
'orderid': '1',
}, delivery: true);
expect(contact.isEmpty, isTrue);
expect(contact.number, '');
});
test('a blank or placeholder number counts as none', () {
for (final junk in const ['', ' ', '0', 'null']) {
expect(
StopContact.forLeg({
'pickupcontactno': junk,
}, delivery: false).isEmpty,
isTrue,
reason: '"$junk" must not reach a dialer',
);
}
});
test('the older spellings still resolve', () {
expect(
StopContact.forLeg(const {
'PickupContactNo': '9000000003',
}, delivery: false).number,
'9000000003',
);
expect(
StopContact.forLeg(const {
'customerphone': '9000000004',
}, delivery: true).number,
'9000000004',
);
});
});
}