device infos
This commit is contained in:
@@ -402,17 +402,73 @@ void main() {
|
||||
expect(s['dropaddress'], 'Flat 3, Anna Nagar');
|
||||
});
|
||||
|
||||
test('a booking without source fields does not invent one', () {
|
||||
// BACKEND DEPENDENCY: sourceid/sourcename are not deployed. Until they
|
||||
// are, every order groups under one unnamed bucket — visibly wrong, and
|
||||
// deliberately not papered over with a guessed kitchen name.
|
||||
test('a booking without source fields is never given a name', () {
|
||||
// BACKEND DEPENDENCY: sourceid/sourcename are not deployed everywhere.
|
||||
// The rule that matters is unchanged and is what this asserts: the app
|
||||
// does not paper over a missing counter with a guessed kitchen name.
|
||||
final s = ApiConfig.pickupFromBooking({
|
||||
'bookingid': 43,
|
||||
'bookingreference': 'DM-43',
|
||||
'pickupaddress': '9 Mettupalayam Road',
|
||||
});
|
||||
expect(MilkRun.sourceNameOf(s), '');
|
||||
expect(MilkRun.sourceKeyOf(s), 'none');
|
||||
});
|
||||
|
||||
test('...but it still groups by the address it does carry', () {
|
||||
// ── What changed, and why it is not "inventing" one ──
|
||||
//
|
||||
// This used to demand `'none'`, which put every source-less order in one
|
||||
// bucket regardless of where it was collected. On a real morning that
|
||||
// failed in the other direction: eight orders off one kitchen, seven
|
||||
// carrying its id and one not, and the eighth could not join them — it
|
||||
// fell out of the dropdown into a flat header of its own titled with the
|
||||
// customer's name.
|
||||
//
|
||||
// Keying on the address invents nothing. It is the weakest *true*
|
||||
// statement on the row — these are collected from the same address — and
|
||||
// it is only reached when the id and the name are both absent. The name
|
||||
// is still empty, which is what the test above pins.
|
||||
Map<String, dynamic> at(String address) =>
|
||||
ApiConfig.pickupFromBooking({
|
||||
'bookingid': address.hashCode,
|
||||
'bookingreference': 'DM-$address',
|
||||
'pickupaddress': address,
|
||||
});
|
||||
|
||||
// Same counter, spelled as two different rows would spell it.
|
||||
expect(
|
||||
MilkRun.sourceKeyOf(at('9 Mettupalayam Road')),
|
||||
MilkRun.sourceKeyOf(at('9, METTUPALAYAM ROAD ')),
|
||||
);
|
||||
// A different place stays a different group.
|
||||
expect(
|
||||
MilkRun.sourceKeyOf(at('9 Mettupalayam Road')),
|
||||
isNot(MilkRun.sourceKeyOf(at('12 SNS Colony'))),
|
||||
);
|
||||
// Nothing to group on at all is still its own bucket, never a guess.
|
||||
expect(
|
||||
MilkRun.sourceKeyOf(
|
||||
ApiConfig.pickupFromBooking({
|
||||
'bookingid': 44,
|
||||
'bookingreference': 'DM-44',
|
||||
}),
|
||||
),
|
||||
'none',
|
||||
);
|
||||
});
|
||||
|
||||
test('an identified counter still outranks the address', () {
|
||||
// Order of trust: the hub's id, then the name it reads by, then where it
|
||||
// is. Two kitchens at one address must not merge because a row lost its
|
||||
// id; two rows with the same id must not split because someone retyped
|
||||
// the address.
|
||||
final byId = ApiConfig.pickupFromBooking({
|
||||
'bookingid': 45,
|
||||
'bookingreference': 'DM-45',
|
||||
'sourceid': 'K1',
|
||||
'pickupaddress': '9 Mettupalayam Road',
|
||||
});
|
||||
expect(MilkRun.sourceKeyOf(byId), 'id:K1');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user