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>
112 lines
3.8 KiB
Dart
112 lines
3.8 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:miler/views/offline/offline_banner.dart';
|
|
import 'package:miler/views/helpers/constants/Colorconstants.dart';
|
|
|
|
/// ── Losing signal must not take the job away ──
|
|
///
|
|
/// Connectivity used to stack an opaque full-screen page over the entire app.
|
|
/// A rider at a doorstep in a basement lost the address, the customer, the
|
|
/// parcel count and the OTP field — while holding the parcel. Everything he
|
|
/// needs at the door was already fetched; the network is needed to *report* the
|
|
/// stop, not to work it.
|
|
void main() {
|
|
Future<void> pump(WidgetTester tester, {required bool offline}) async {
|
|
tester.view.physicalSize = const Size(390 * 3, 844 * 3);
|
|
tester.view.devicePixelRatio = 3.0;
|
|
addTearDown(tester.view.reset);
|
|
|
|
await tester.pumpWidget(
|
|
ScreenUtilInit(
|
|
designSize: const Size(390, 844),
|
|
builder: (_, _) => MaterialApp(
|
|
home: OfflineScope(
|
|
offline: offline,
|
|
child: Scaffold(
|
|
body: Column(
|
|
children: const [
|
|
Text('45, Lake View Apartments'),
|
|
Text('Priya Sharma'),
|
|
Text('Delivery OTP'),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
}
|
|
|
|
testWidgets('the job stays on screen while offline', (tester) async {
|
|
await pump(tester, offline: true);
|
|
|
|
// The four things a rider cannot do the stop without.
|
|
expect(find.text('45, Lake View Apartments'), findsOneWidget);
|
|
expect(find.text('Priya Sharma'), findsOneWidget);
|
|
expect(find.text('Delivery OTP'), findsOneWidget);
|
|
expect(find.byType(OfflineBanner), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('the strip takes its own row — it never covers content', (
|
|
tester,
|
|
) async {
|
|
await pump(tester, offline: true);
|
|
|
|
// A Column, not a Stack, on purpose: a floating bar over the page would sit
|
|
// on top of the OTP box, which is worse than the blocker it replaced.
|
|
final strip = tester.getRect(find.byType(OfflineBanner));
|
|
final firstContent = tester.getRect(find.text('45, Lake View Apartments'));
|
|
expect(strip.bottom, lessThanOrEqualTo(firstContent.top));
|
|
});
|
|
|
|
testWidgets('it is thin enough to cost the job nothing', (tester) async {
|
|
await pump(tester, offline: true);
|
|
// Roughly one line plus padding. A "banner" that eats 15% of an 844pt
|
|
// screen is a blocker with a nicer name.
|
|
expect(tester.getSize(find.byType(OfflineBanner)).height, lessThan(64));
|
|
});
|
|
|
|
testWidgets('it says what happens next, not just what is wrong', (
|
|
tester,
|
|
) async {
|
|
await pump(tester, offline: true);
|
|
final text = tester
|
|
.widgetList<Text>(
|
|
find.descendant(
|
|
of: find.byType(OfflineBanner),
|
|
matching: find.byType(Text),
|
|
),
|
|
)
|
|
.first
|
|
.data!;
|
|
expect(text, contains('Offline'));
|
|
expect(text.toLowerCase(), contains('sync'));
|
|
});
|
|
|
|
testWidgets('online, it occupies no space at all', (tester) async {
|
|
await pump(tester, offline: false);
|
|
expect(find.byType(OfflineBanner), findsNothing);
|
|
expect(
|
|
tester.getRect(find.text('45, Lake View Apartments')).top,
|
|
lessThan(20),
|
|
);
|
|
});
|
|
|
|
testWidgets('the strip carries a readable label on its fill', (tester) async {
|
|
await pump(tester, offline: true);
|
|
final material = tester.widget<Material>(
|
|
find
|
|
.descendant(
|
|
of: find.byType(OfflineBanner),
|
|
matching: find.byType(Material),
|
|
)
|
|
.first,
|
|
);
|
|
// `warning`, which the contrast contract holds to 4.5:1 behind white.
|
|
expect(material.color, ColorConstants.warning);
|
|
});
|
|
}
|