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>
126 lines
4.0 KiB
Dart
126 lines
4.0 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:slide_to_submit_button/slide_to_submit_button.dart';
|
|
|
|
import 'package:miler/views/Dashboard/home/duty_sheet.dart';
|
|
|
|
/// The duty sheet used to say one thing — "You will stop receiving bookings" —
|
|
/// and leave out the two that actually catch a rider out: tracking stops, and
|
|
/// the app will refuse to take him off duty while he is still holding work. It
|
|
/// also carried a wifi glyph, which says "network problem" on a screen about
|
|
/// whether he is working.
|
|
void main() {
|
|
Future<void> pump(
|
|
WidgetTester tester, {
|
|
required bool goingOnline,
|
|
Future<bool> Function()? onConfirm,
|
|
}) async {
|
|
tester.view.physicalSize = const Size(1170, 2532);
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
await tester.pumpWidget(
|
|
ScreenUtilInit(
|
|
designSize: const Size(390, 844),
|
|
builder: (_, _) => MaterialApp(
|
|
home: Scaffold(
|
|
body: Align(
|
|
alignment: Alignment.bottomCenter,
|
|
child: DutySheet(
|
|
goingOnline: goingOnline,
|
|
onConfirm: onConfirm ?? () async => true,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
// The hint arrow loops forever, so there is nothing to settle into.
|
|
await tester.pump(const Duration(milliseconds: 300));
|
|
}
|
|
|
|
testWidgets('going on duty names the state it is heading for', (
|
|
tester,
|
|
) async {
|
|
await pump(tester, goingOnline: true);
|
|
|
|
expect(find.text('Go on duty?'), findsOneWidget);
|
|
expect(find.text('Go on duty'), findsOneWidget);
|
|
expect(find.text('Not yet'), findsOneWidget);
|
|
|
|
// Duty is not connectivity. A rider reading a wifi symbol on a screen that
|
|
// stops his work is being told the app has a network problem.
|
|
expect(find.byIcon(Icons.wifi), findsNothing);
|
|
expect(find.byIcon(Icons.wifi_off), findsNothing);
|
|
});
|
|
|
|
// ── The consequence survives; the three rows that carried it do not ──
|
|
//
|
|
// The sheet listed what stops as three icon-and-text rows. The facts are the
|
|
// contract, not the rows — and the one that matters most is the refusal,
|
|
// which the original sheet sprang on the rider only *after* he had completed
|
|
// a slide. It is in the sentence now, before he decides.
|
|
testWidgets('going off duty states what stops, including the refusal', (
|
|
tester,
|
|
) async {
|
|
await pump(tester, goingOnline: false);
|
|
|
|
expect(find.text('Go off duty?'), findsOneWidget);
|
|
|
|
final body = tester
|
|
.widgetList<Text>(find.byType(Text))
|
|
.map((t) => t.data ?? '')
|
|
.join(' ');
|
|
expect(body, contains('stops assigning you trips'));
|
|
expect(body, contains('live tracking pauses'));
|
|
expect(
|
|
body,
|
|
contains('has to be finished first'),
|
|
reason: 'the refusal must be stated before the gesture, not after it',
|
|
);
|
|
});
|
|
|
|
// ── Slides are reserved for money ──
|
|
//
|
|
// The confirmation was a slide-to-submit borrowed from the payment flows.
|
|
// Ending a shift is not a transaction, and asking for a drag made the
|
|
// commonest action of the rider's day the most laborious one.
|
|
testWidgets('confirming runs the toggle', (tester) async {
|
|
var calls = 0;
|
|
await pump(
|
|
tester,
|
|
goingOnline: true,
|
|
onConfirm: () async {
|
|
calls++;
|
|
return true;
|
|
},
|
|
);
|
|
|
|
await tester.tap(find.widgetWithText(ElevatedButton, 'Go on duty'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(calls, 1);
|
|
});
|
|
|
|
testWidgets('dismissing does not', (tester) async {
|
|
var calls = 0;
|
|
await pump(
|
|
tester,
|
|
goingOnline: false,
|
|
onConfirm: () async {
|
|
calls++;
|
|
return true;
|
|
},
|
|
);
|
|
|
|
await tester.tap(find.text('Stay on duty'));
|
|
await tester.pump();
|
|
await tester.pump();
|
|
|
|
expect(calls, 0, reason: 'the way out must not perform the action');
|
|
});
|
|
}
|