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>
280 lines
8.4 KiB
Dart
280 lines
8.4 KiB
Dart
@Tags(['shots'])
|
|
library;
|
|
|
|
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 'support/golden_fonts.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';
|
|
import 'package:miler/views/helpers/constants/Colorconstants.dart';
|
|
import 'package:miler/views/helpers/constants/Font_constant.dart';
|
|
|
|
/// Visual harness for the bottom sheets.
|
|
///
|
|
/// Each sheet body is pumped **through its own `show` entry point** where one
|
|
/// exists, over a busy stand-in page — a sheet is never seen against a blank
|
|
/// screen, and the barrier + rounded shape + background are exactly the things
|
|
/// being unified, so the shot must include them. Run with `--update-goldens`.
|
|
void main() {
|
|
setUpAll(() async {
|
|
// The detail sheet's map caches tiles through path_provider, which has no
|
|
// host in a test binding. Point it at the test runner's temp dir; the
|
|
// tiles themselves never load (no network in tests) and flutter_map
|
|
// degrades to its plain ground, which is fine for a layout shot.
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(
|
|
const MethodChannel('plugins.flutter.io/path_provider'),
|
|
(call) async => Directory.systemTemp
|
|
.createTemp('sheet_shots')
|
|
.then((d) => d.path),
|
|
);
|
|
await loadGoldenFonts();
|
|
});
|
|
|
|
tearDown(() {
|
|
Get.reset();
|
|
ServiceProfile.setActive(ServiceProfile.parcel);
|
|
});
|
|
|
|
const lines = [
|
|
BagLine(stop: {}, orderId: 'D1', customer: 'Joe Mathew', bag: 'Bag 1'),
|
|
BagLine(stop: {}, orderId: 'D2', customer: 'Arun Prakash', bag: 'Bag 2'),
|
|
BagLine(stop: {}, orderId: 'D3', customer: 'Priya Nair', bag: 'Bag 3'),
|
|
BagLine(stop: {}, orderId: 'D4', customer: 'Ravi Kumar', bag: 'Bag 4'),
|
|
BagLine(stop: {}, orderId: 'D5', customer: 'Kumar S', bag: 'Bag 5'),
|
|
];
|
|
|
|
Map<String, dynamic> stop() => {
|
|
'orderid': 'D1',
|
|
'bookingno': 'DM-BK-16DA518D-6381',
|
|
'type': 'delivery',
|
|
'pickupcustomer': 'Joe Mathew',
|
|
'name': 'Joe Mathew',
|
|
'sourcename': 'Vidhya Kitchen',
|
|
'kitchenname': 'Vidhya 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': '2450',
|
|
'pickuplat': 11.0168,
|
|
'pickuplon': 76.9558,
|
|
'droplat': 11.0208,
|
|
'droplon': 76.9598,
|
|
};
|
|
|
|
/// A stand-in for the page under the sheet: enough structure that the
|
|
/// barrier's dim and the sheet's edge read against something real.
|
|
Widget ground() => Scaffold(
|
|
backgroundColor: ColorConstants.daylightSurface,
|
|
body: ListView(
|
|
padding: const EdgeInsets.all(24),
|
|
children: [
|
|
for (var i = 0; i < 10; i++)
|
|
Padding(
|
|
padding: const EdgeInsets.only(bottom: 14),
|
|
child: Container(
|
|
height: 84,
|
|
decoration: BoxDecoration(
|
|
color: ColorConstants.pureSurface,
|
|
borderRadius: BorderRadius.circular(16),
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
);
|
|
|
|
Future<void> shoot(
|
|
WidgetTester tester,
|
|
String name,
|
|
Future<void> Function(BuildContext) open, {
|
|
double width = 390,
|
|
double height = 844,
|
|
double textScale = 1.0,
|
|
}) async {
|
|
ServiceProfile.setActive(ServiceProfile.milkMan);
|
|
SharedPreferences.setMockInitialValues({'userid': 1});
|
|
|
|
tester.view.physicalSize = Size(width * 3, height * 3);
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.reset);
|
|
|
|
late BuildContext pageContext;
|
|
await tester.pumpWidget(
|
|
// A RepaintBoundary of our own to capture from. Capturing a finder with
|
|
// no boundary makes the framework re-composite the retained layers, and
|
|
// an animated CTA's layer can land at its pre-flight offset — the first
|
|
// run of these shots had a ghost "Start navigation" floating at the top
|
|
// of the barrier. A real boundary repaints the whole tree at capture.
|
|
RepaintBoundary(
|
|
child: ScreenUtilInit(
|
|
designSize: Size(width, height),
|
|
builder: (_, _) => MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
// Above the Navigator, not around `home`: a modal sheet is its own
|
|
// route, and an override wrapped around the page never reaches it —
|
|
// the first cut of this harness was quietly shooting every sheet at
|
|
// 1.0x while claiming 1.3x.
|
|
builder: (context, child) => MediaQuery(
|
|
data: MediaQuery.of(
|
|
context,
|
|
).copyWith(textScaler: TextScaler.linear(textScale)),
|
|
child: child!,
|
|
),
|
|
home: Builder(
|
|
builder: (c) {
|
|
pageContext = c;
|
|
return ground();
|
|
},
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
unawaited(open(pageContext));
|
|
await tester.pumpAndSettle(const Duration(seconds: 1));
|
|
|
|
await expectLater(
|
|
find.byType(RepaintBoundary).first,
|
|
matchesGoldenFile('shots/sheet_$name.png'),
|
|
);
|
|
}
|
|
|
|
testWidgets('duty — going on', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'duty_on',
|
|
(c) => DutySheet.show(c, goingOnline: true, onConfirm: () async => false),
|
|
);
|
|
});
|
|
|
|
testWidgets('duty — going off', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'duty_off',
|
|
(c) =>
|
|
DutySheet.show(c, goingOnline: false, onConfirm: () async => false),
|
|
);
|
|
});
|
|
|
|
testWidgets('stop detail', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'detail',
|
|
(c) => StopDetailSheet.show(
|
|
c,
|
|
stop: stop(),
|
|
stopNumber: 1,
|
|
riderLat: 11.0168,
|
|
riderLng: 76.9558,
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('confirm arrival', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'action_arrive',
|
|
(c) => StopActionSheet.show(
|
|
c,
|
|
stage: StopStatus.accepted,
|
|
placeName: 'Vidhya Kitchen',
|
|
count: 5,
|
|
lines: lines,
|
|
onConfirm: (_) async => null,
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('confirm picked', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'action_picked',
|
|
(c) => StopActionSheet.show(
|
|
c,
|
|
stage: StopStatus.arrived,
|
|
placeName: 'Vidhya Kitchen',
|
|
count: 5,
|
|
lines: lines,
|
|
onConfirm: (_) async => null,
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('pickup preview', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'preview',
|
|
(c) => PickupPreviewSheet.show(
|
|
c,
|
|
placeName: 'Vidhya Kitchen',
|
|
lines: lines,
|
|
meters: 3100,
|
|
ride: const Duration(minutes: 9),
|
|
riderLat: 11.0168,
|
|
riderLng: 76.9558,
|
|
onNavigate: () {},
|
|
onCall: () {},
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('stop detail with notes and a long name', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'detail_long',
|
|
(c) => StopDetailSheet.show(
|
|
c,
|
|
stop: {
|
|
...stop(),
|
|
'pickupcustomer': 'Venkataraman Subramanian',
|
|
'name': 'Venkataraman Subramanian',
|
|
'sourcename': 'DailyGrubs RS Puram Central Kitchen',
|
|
'collectionamt': '123456',
|
|
'notes': 'Gate code 4411, leave with security if unreachable.',
|
|
},
|
|
stopNumber: 7,
|
|
bag: 'Bag 1',
|
|
riderLat: 11.0168,
|
|
riderLng: 76.9558,
|
|
),
|
|
);
|
|
});
|
|
|
|
testWidgets('confirm arrival on a 320pt phone at 1.3x', (tester) async {
|
|
await shoot(
|
|
tester,
|
|
'action_arrive_small',
|
|
(c) => StopActionSheet.show(
|
|
c,
|
|
stage: StopStatus.accepted,
|
|
placeName: 'Vidhya Kitchen',
|
|
count: 5,
|
|
lines: lines,
|
|
onConfirm: (_) async => null,
|
|
),
|
|
width: 320,
|
|
textScale: 1.3,
|
|
);
|
|
});
|
|
}
|