Files
doormile_milderapp/test/sheet_layout_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

193 lines
6.0 KiB
Dart

import 'dart:async' show unawaited;
import 'dart:io';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:get/get.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:miler/Models/stop_status.dart';
import 'package:miler/data/bag_manifest.dart';
import 'package:miler/data/service_profile.dart';
import 'package:miler/views/Dashboard/home/duty_sheet.dart';
import 'package:miler/views/Dashboard/home/pickup_preview_sheet.dart';
import 'package:miler/views/Dashboard/home/stop_action_sheet.dart';
import 'package:miler/views/Dashboard/home/stop_detail_sheet.dart';
/// ─────────────────────────────────────────────────────────────────────────
/// THE SHEETS, ACROSS THE PHONES THIS SHIPS TO
///
/// Same shape as `activity_layout_test`: every rider-path sheet, opened
/// through its real `show` entry point (so the route, fabric and insets are
/// the ones production uses), at the four widths the brief names against the
/// text scales Android exposes. One assertion — **nothing throws** — because
/// a `RenderFlex` overflow is an exception under the test binding and that is
/// the cheapest honest "does it fit?".
/// ─────────────────────────────────────────────────────────────────────────
void main() {
setUpAll(() {
// The detail sheet's map caches tiles through path_provider, which has no
// host under the test binding.
TestWidgetsFlutterBinding.ensureInitialized();
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(
const MethodChannel('plugins.flutter.io/path_provider'),
(call) async => Directory.systemTemp
.createTemp('sheet_layout')
.then((d) => d.path),
);
});
tearDown(() {
Get.reset();
ServiceProfile.setActive(ServiceProfile.parcel);
});
const widths = [320.0, 375.0, 390.0, 412.0];
const textScales = [1.0, 1.3, 2.0];
const lines = [
BagLine(
stop: {},
orderId: 'D1',
customer: 'Venkataraman Subramanian',
bag: 'Bag 1',
),
BagLine(stop: {}, orderId: 'D2', customer: 'Arun Prakash', bag: 'Bag 2'),
BagLine(stop: {}, orderId: 'D3', customer: 'Priya Nair', bag: 'Bag 3'),
];
Map<String, dynamic> stop() => {
'orderid': 'D1',
'type': 'delivery',
'pickupcustomer': 'Venkataraman Subramanian',
'sourcename': 'DailyGrubs RS Puram Central Kitchen',
'pickupaddress': '4 Cross, RS Puram, Coimbatore 641002',
'dropaddress': '12, SNS Colony, Peelamedu, Coimbatore 641004',
'orderstatus': 'accepted',
'pickupcontactno': '9787698259',
'baglabel': 'Bag 1',
'Quantity': 1,
'collectionamt': '123456',
'notes': 'Gate code 4411, leave with security if unreachable.',
'pickuplat': 11.0168,
'pickuplon': 76.9558,
'droplat': 11.0208,
'droplon': 76.9598,
};
Future<void> sweep(
WidgetTester tester,
double width,
double scale,
Future<void> Function(BuildContext) open,
) async {
ServiceProfile.setActive(ServiceProfile.milkMan);
SharedPreferences.setMockInitialValues({'userid': 1});
tester.view.physicalSize = Size(width * 3, 844 * 3);
tester.view.devicePixelRatio = 3.0;
addTearDown(tester.view.reset);
late BuildContext ctx;
await tester.pumpWidget(
ScreenUtilInit(
designSize: const Size(390, 844),
builder: (_, _) => MaterialApp(
builder: (context, child) => MediaQuery(
data: MediaQuery.of(
context,
).copyWith(textScaler: TextScaler.linear(scale)),
child: child!,
),
home: Builder(
builder: (c) {
ctx = c;
return const Scaffold(body: SizedBox.expand());
},
),
),
),
);
unawaited(open(ctx));
await tester.pumpAndSettle(const Duration(seconds: 1));
expect(
tester.takeException(),
isNull,
reason: 'the sheet overflowed at ${width}pt / ${scale}x',
);
}
for (final width in widths) {
for (final scale in textScales) {
final tag = '${width.toInt()}pt / ${scale}x';
testWidgets('duty fits $tag', (tester) async {
await sweep(
tester,
width,
scale,
(c) => DutySheet.show(
c,
goingOnline: true,
onConfirm: () async => false,
),
);
});
testWidgets('the rung confirmation fits $tag', (tester) async {
await sweep(
tester,
width,
scale,
(c) => StopActionSheet.show(
c,
stage: StopStatus.arrived,
placeName: 'DailyGrubs RS Puram Central Kitchen',
count: 3,
lines: lines,
onConfirm: (_) async => null,
),
);
});
testWidgets('the pickup preview fits $tag', (tester) async {
await sweep(
tester,
width,
scale,
(c) => PickupPreviewSheet.show(
c,
placeName: 'DailyGrubs RS Puram Central Kitchen',
lines: lines,
meters: 3100,
ride: const Duration(minutes: 9),
onNavigate: () {},
onCall: () {},
),
);
});
testWidgets('the stop detail fits $tag', (tester) async {
await sweep(
tester,
width,
scale,
(c) => StopDetailSheet.show(
c,
stop: stop(),
stopNumber: 7,
bag: 'Bag 1',
riderLat: 11.0168,
riderLng: 76.9558,
),
);
});
}
}
}