Picks up where 0d66627 left off. Three things.
SIGN-IN, CUT TO THE QUESTION IT ASKS
It opened with a quarter-screen crimson hero carrying a lockup, a CUSTOMER
badge, a display-size promise and a sub-line, then a Phone/Email toggle, then a
labelled field, then a card explaining what a verification code is. Six things
to read before the one thing to do.
Nobody arrives at a sign-in screen needing to be sold the product. It is a
heading, a field and a button now, which is where Uber, Bolt and Porter put
them. The toggle became one quiet line under the field — choosing a method was
the first decision on the screen, before the customer had seen what was being
asked, and almost everyone uses the phone. The privacy card went: it explained
that a code would be sent, which the next screen demonstrates a second later.
`DmTextField.label` is nullable for this — "Enter your mobile number" above a
field captioned "Phone number" is one sentence printed twice.
BOOKING, DOWN TO ONE SCREENFUL
Landmark, recipient name and recipient phone are all optional and were all
drawn at the weight of the two fields that are not, putting six rows of "you
may skip this" between the address and the button. They fold behind one row
that counts what is filled in rather than just saying "optional".
Four crimson section heads became one. An accent used five times on a screen is
not an accent; crimson now marks the destination, which is the only choice that
changes the price.
Together those put the window, the package count and the CTA above the fold.
THE OFFLINE BUILD, BACK, UNDER TWO RULES
Deleted on 15 Sep after it cost two rounds of hunting for bookings in the admin
console that had never left the phone. That was not caused by the fake
existing — it was caused by a fake that did not announce itself and that
nothing stopped from shipping. Both are closed:
* `useDevData` is false in a release whatever the defines say;
* `describe` leads with DEV DATA (offline) and shows "no network" rather than
a host the build never contacts.
It is opt-in — `flutter run` still talks to the real API — which is the
property whose absence caused the original mess. `devAutoLogin` is deliberately
false under FLUTTER_TEST so the widget tests keep driving the real entrance.
flutter run --dart-define=DM_MOCK=true
86 tests green, analyze clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EqVJPB9B4QuieZnBAAKgYQ
174 lines
5.9 KiB
Dart
174 lines
5.9 KiB
Dart
@Tags(['snapshot'])
|
|
library;
|
|
|
|
import 'package:doormile_cx/data/dev_doormile_api.dart';
|
|
import 'package:doormile_cx/data/doormile_api.dart';
|
|
import 'package:doormile_cx/data/location_service.dart';
|
|
import 'package:doormile_cx/main.dart';
|
|
import 'package:doormile_cx/state/app_state.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:lucide_icons_flutter/lucide_icons.dart';
|
|
import 'package:flutter/services.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
/// Renders each screen at phone size and writes it to `test/snapshots/`.
|
|
///
|
|
/// This is a **design** check, not a regression check. A deliberate redesign
|
|
/// would fail every one of these, which is worthless as a test signal, so the
|
|
/// `snapshot` tag is skipped in a normal run (see `dart_test.yaml`) and the
|
|
/// pictures are rendered on demand:
|
|
///
|
|
/// flutter test test/design_snapshot_test.dart --run-skipped --update-goldens
|
|
///
|
|
/// It exists because the only honest way to review a visual rebuild is to look
|
|
/// at it, and this produces the same pictures on any machine, with the real
|
|
/// fonts, without a device attached.
|
|
///
|
|
/// The real fonts are loaded first — without that, Flutter's test harness draws
|
|
/// everything in Ahem's black boxes and the pictures are worthless.
|
|
Future<void> _loadFonts() async {
|
|
for (final (family, asset) in const [
|
|
('Manrope', 'assets/fonts/Manrope-VF.ttf'),
|
|
('GeistMono', 'assets/fonts/GeistMono-VF.ttf'),
|
|
// The icon font too, or every glyph in the picture is a hollow box.
|
|
('packages/lucide_icons_flutter/Lucide',
|
|
'packages/lucide_icons_flutter/assets/lucide.ttf'),
|
|
]) {
|
|
final loader = FontLoader(family)..addFont(rootBundle.load(asset));
|
|
await loader.load();
|
|
}
|
|
}
|
|
|
|
Future<void> _settle(WidgetTester tester, [int ms = 800]) async {
|
|
await tester.pump();
|
|
await tester.pump(Duration(milliseconds: ms));
|
|
await tester.pump(const Duration(milliseconds: 400));
|
|
}
|
|
|
|
Future<void> _shot(WidgetTester tester, String name) async {
|
|
await expectLater(
|
|
find.byType(MaterialApp),
|
|
matchesGoldenFile('snapshots/$name.png'),
|
|
);
|
|
}
|
|
|
|
void main() {
|
|
late DevDoormileApi api;
|
|
|
|
setUp(() {
|
|
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
|
|
.setMockMethodCallHandler(
|
|
const MethodChannel('plugins.flutter.io/path_provider'),
|
|
(call) async => '/tmp',
|
|
);
|
|
api = DevDoormileApi();
|
|
DoormileApi.overrideInstance(api);
|
|
LocationService.instance = FixedLocationService();
|
|
});
|
|
|
|
tearDown(() => DoormileApi.overrideInstance(null));
|
|
|
|
testWidgets('screens', (tester) async {
|
|
await _loadFonts();
|
|
|
|
// One phone, portrait: 390x844 at 3x, the frame the design was drawn in.
|
|
tester.view.physicalSize = const Size(1170, 2532);
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.reset);
|
|
|
|
final state = AppState();
|
|
await tester.pumpWidget(DoormileApp(initialState: state));
|
|
await _settle(tester);
|
|
|
|
// Image.asset resolves off the frame loop, so in a test it never paints
|
|
// unless it is decoded first — without this the wordmark is a blank gap in
|
|
// every picture of the entrance.
|
|
await tester.runAsync(() async {
|
|
await precacheImage(
|
|
const AssetImage('assets/images/doormile-logo.png'),
|
|
tester.element(find.byType(MaterialApp)),
|
|
);
|
|
});
|
|
await _settle(tester);
|
|
await _shot(tester, '01-sign-in');
|
|
|
|
await tester.tap(find.text('Create account'));
|
|
await _settle(tester);
|
|
await _shot(tester, '01b-sign-up');
|
|
await tester.tap(find.byIcon(LucideIcons.arrowLeft).first);
|
|
await _settle(tester);
|
|
|
|
await tester.enterText(find.byType(TextField).first, '9876543210');
|
|
await _settle(tester, 200);
|
|
await tester.tap(find.text('Continue'));
|
|
await _settle(tester);
|
|
await _shot(tester, '02-verify');
|
|
|
|
final boxes = find.byType(TextField);
|
|
for (var i = 0; i < 4; i++) {
|
|
await tester.enterText(boxes.at(i), '1');
|
|
await tester.pump();
|
|
}
|
|
await _settle(tester);
|
|
await _shot(tester, '03-home');
|
|
|
|
await tester.tap(find.text('Orders'));
|
|
await _settle(tester);
|
|
await _shot(tester, '04-orders');
|
|
|
|
await tester.tap(find.text('Account'));
|
|
await _settle(tester);
|
|
await _shot(tester, '05-account');
|
|
|
|
await tester.tap(find.text('Home'));
|
|
await _settle(tester);
|
|
await tester.tap(find.text('Miler assigned'));
|
|
await _settle(tester);
|
|
await _shot(tester, '06-tracking');
|
|
await tester.tap(find.byIcon(LucideIcons.arrowLeft).first);
|
|
await _settle(tester);
|
|
|
|
// Booking: one screen, plus the two escape hatches.
|
|
await tester.tap(find.text('Start booking'));
|
|
await _settle(tester);
|
|
await _shot(tester, '07-send-empty');
|
|
|
|
await tester.tap(find.text('Chennai').first);
|
|
await _settle(tester);
|
|
await _shot(tester, '08-send-ready');
|
|
|
|
// The window row is below the fold on a phone, and a ListView does not
|
|
// build what it has not reached.
|
|
// The window already carries the first available slot, so scroll to the
|
|
// package row beneath it — a string that is there either way.
|
|
await tester.dragUntilVisible(
|
|
find.text('1 package'),
|
|
find.byType(Scrollable).first,
|
|
const Offset(0, -220),
|
|
);
|
|
await _settle(tester);
|
|
await tester.tap(find.text('Change').last);
|
|
await _settle(tester);
|
|
await _shot(tester, '09-window-sheet');
|
|
await tester.tap(find.textContaining('Use ').first);
|
|
await _settle(tester);
|
|
|
|
await tester.tap(find.text('Book pickup'));
|
|
await _settle(tester);
|
|
await _shot(tester, '11-booked');
|
|
|
|
// A finished order, for the receipt treatment.
|
|
await tester.tap(find.text('Back to home'));
|
|
await _settle(tester);
|
|
await tester.tap(find.text('Orders'));
|
|
await _settle(tester);
|
|
await tester.tap(find.text('Completed'));
|
|
await _settle(tester);
|
|
await tester.tap(find.text('Salem, Tamil Nadu'));
|
|
await _settle(tester);
|
|
await _shot(tester, '12-receipt');
|
|
|
|
await tester.pump(const Duration(seconds: 3));
|
|
});
|
|
}
|