device infos

This commit is contained in:
2026-08-28 15:07:30 +05:30
parent 5723d373b2
commit 69f4f3e909
84 changed files with 4337 additions and 2339 deletions

View File

@@ -27,8 +27,14 @@ import 'package:miler/views/helpers/constants/Colorconstants.dart';
void main() {
tearDown(() => ServiceProfile.setActive(ServiceProfile.parcel));
Map<String, dynamic> meal(String id, String who, {int step = 1}) => {
Map<String, dynamic> meal(
String id,
String who, {
int step = 1,
String? printed,
}) => {
'orderid': id,
if (printed != null) 'baglabel': printed,
'type': 'delivery',
'step': step,
'pickupcustomer': who,
@@ -48,6 +54,10 @@ void main() {
void Function(String)? onToggleSelect,
double width = 390,
double textScale = 1.0,
/// What each counter printed on an order, by id. Empty by default: most
/// counters print nothing, and the app invents nothing for them.
Map<String, String> printedLabels = const {},
}) async {
ServiceProfile.setActive(ServiceProfile.milkMan);
tester.view.physicalSize = Size(width * 3, 2600 * 3);
@@ -57,9 +67,9 @@ void main() {
final trip = Trip.fromStops(
id: 'run',
stops: [
meal('1', 'Joe Mathew', step: 1),
meal('2', 'Arun Prakash', step: 2),
meal('3', 'Ravi Kumar', step: 3),
meal('1', 'Joe Mathew', step: 1, printed: printedLabels['1']),
meal('2', 'Arun Prakash', step: 2, printed: printedLabels['2']),
meal('3', 'Ravi Kumar', step: 3, printed: printedLabels['3']),
],
);
@@ -276,35 +286,72 @@ void main() {
expect(opened, isEmpty);
});
testWidgets('the bag block opens details, and does not select', (
testWidgets('the corner block opens details, and does not select', (
tester,
) async {
final selected = <String>[];
await pumpHome(tester, onToggleSelect: selected.add);
// The tag is the counter's printed label now — the derived `Bag 1` is
// gone — so the block is tapped by the label the kitchen really stuck on.
await pumpHome(
tester,
onToggleSelect: selected.add,
printedLabels: const {'1': 'DG-1042'},
);
await openKitchen(tester);
// Siblings, never nested: two recognisers over the same pixels resolve
// to neither, which is how the chevron was once dead for a whole build.
await tester.tap(find.text('Bag 1'));
await tester.tap(find.text('DG-1042'));
await tester.pumpAndSettle();
expect(
selected,
isEmpty,
reason: 'the bag corner is the way in, not a second tick',
reason: 'the corner is the way in, not a second tick',
);
});
});
group('the metadata is metadata', () {
testWidgets('Pending is neutral, not a warning', (tester) async {
testWidgets('Pending is its own amber, and never the warning one', (
tester,
) async {
await pumpHome(tester);
// Amber is this app's exception hue. On a fresh morning every kitchen is
// pending, so spending it here opens the whole screen in warning and
// leaves nothing to say with when a stop genuinely goes wrong.
final word = tester.widget<Text>(find.text('Pending'));
expect(word.style!.color, ColorConstants.secondaryText);
// ── What this test used to assert, and what survives of it ──
//
// It demanded neutral grey, on the argument that amber is this app's
// exception hue and every kitchen is pending on a fresh morning — so
// spending it here opens the whole screen in warning.
//
// Half of that argument is still load-bearing and is still checked: the
// word must not be [ColorConstants.warning]. The other half was wrong —
// "waiting on you" is worth a colour of its own, and grey made the rider
// read undecided work by the *absence* of a mark. Pending has its own
// gold now; the thing that must never happen is it colliding with the
// hue reserved for a skip or a short payment.
// `Pending 3/3` — the word carries the count now, the same way Accepted
// states its share of a counter. See the chip in `route_timeline.dart`.
final word = tester.widget<Text>(find.textContaining('Pending'));
expect(word.data, 'Pending 3/3');
expect(word.style!.color, ColorConstants.pendingAmber);
expect(word.style!.color, isNot(ColorConstants.warning));
expect(word.style!.color, isNot(ColorConstants.primary));
});
testWidgets('Accepted is green and Collected is not', (tester) async {
// The two rungs a rider most needs to tell apart on one counter. They
// were both green once — accepted took the brand red only on the group
// being ridden to, and collected took [ColorConstants.acceptGreen] — so
// the pair could render as one hue and two words.
await pumpHome(tester, accepted: const {'1', '2', '3'});
final accepted = tester.widget<Text>(find.textContaining('Accepted'));
expect(accepted.style!.color, ColorConstants.acceptGreen);
expect(
ColorConstants.pickedBlue,
isNot(ColorConstants.acceptGreen),
reason: 'in-hand and taken-on must not share a colour',
);
});
testWidgets('a partly accepted kitchen says so as a fraction', (
@@ -333,9 +380,9 @@ void main() {
// plus its padding. A page surface is not. Filtering by width keeps the
// original claim — the state is set, not stamped — and makes it immune
// to whatever the page is standing on.
final word = tester.getRect(find.text('Pending'));
final word = tester.getRect(find.textContaining('Pending'));
final chip = find.ancestor(
of: find.text('Pending'),
of: find.textContaining('Pending'),
matching: find.byType(DecoratedBox),
);
for (final e in chip.evaluate()) {
@@ -366,44 +413,40 @@ void main() {
expect(find.text('Peelamedu'), findsWidgets);
});
testWidgets('one order, one bag — and the column is stable', (
tester,
) async {
testWidgets('a counter that prints nothing shows no tag', (tester) async {
// ── What this file used to assert here ──
//
// That every step carried `Bag 1 … Bag 3`, right-aligned on one axis so
// the phone could be read against a shelf. The numbering was the app's
// own — derived from each row's position whenever the payload printed
// nothing, which on this fixture is every row — and it sat two columns
// from a rail already numbering the same steps.
//
// Only what a counter actually printed survives. The fixture prints
// nothing, so the rows carry the person and the chevron and no tag at
// all.
await pumpHome(tester);
await openKitchen(tester);
for (final bag in const ['Bag 1', 'Bag 2', 'Bag 3']) {
expect(find.text(bag), findsOneWidget);
}
// Right-aligned on one axis, so the phone can be read against a shelf.
final rights = [
for (final bag in const ['Bag 1', 'Bag 2', 'Bag 3'])
tester.getRect(find.text(bag)).right,
];
for (final r in rights) {
expect(r, closeTo(rights.first, 0.5));
for (final label in const ['Bag 1', 'Bag 2', 'Bag 3']) {
expect(find.text(label), findsNothing);
}
// The people are still there, one row each.
expect(find.text('Joe Mathew'), findsOneWidget);
});
testWidgets('the name outranks the bag, and the bag yields first', (
testWidgets('a printed label is shown exactly as it was sent', (
tester,
) async {
await pumpHome(tester, textScale: 2.0, width: 320);
// A code the kitchen stuck on the order is a fact about an object in the
// rider's hands, so it travels verbatim — never prefixed, never renamed.
await pumpHome(tester, printedLabels: const {'1': 'DG-1042'});
await openKitchen(tester);
// `Bag 1` is compared against a shelf, not read as prose, so it stops
// scaling before the customer's name does. Left uncapped it took half a
// 320pt row at 2× and the name — the one item that must yield last —
// was what ellipsised.
final bag = tester.getRect(find.text('Bag 1'));
expect(
bag.width,
lessThan(120),
reason: 'the bag column does not grow into the name',
);
expect(tester.takeException(), isNull, reason: 'and nothing overflows');
expect(find.text('DG-1042'), findsOneWidget);
expect(find.textContaining('Bag'), findsNothing);
});
});
group('the offer states its own number', () {