feat(db): lot presentation + attachment sort order (schema v4→v5)
Expand LotType from {seed, plant} to six append-only forms (seed,
seedling, plant, tree, bulb, cutting) and add an optional Presentation
attribute (pot/tray/plug/bareRoot/rootBall) kept separate from quantity
so 'how many' and 'in what packaging' never conflate.
Add attachments.sortOrder so the cover photo is the lowest-ordered one,
enabling reordering from the full-screen viewer. Expand QuantityKind
with the new plant-aware forms.
Migrations are additive (v1→v5 all covered by migration_test); enum
values are stored by name and appended only, keeping CRDT sync safe.
This commit is contained in:
parent
06aed2a586
commit
3954c62aa6
16 changed files with 6174 additions and 32 deletions
|
|
@ -201,6 +201,43 @@ void main() {
|
|||
]);
|
||||
});
|
||||
|
||||
test('setPreferredPhoto moves a photo to the front (cover)', () async {
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
await repo.addPhoto(id, Uint8List.fromList([1]));
|
||||
await repo.addPhoto(id, Uint8List.fromList([2]));
|
||||
final p3 = await repo.addPhoto(id, Uint8List.fromList([3]));
|
||||
|
||||
// Insertion order until a cover is chosen.
|
||||
expect(
|
||||
(await repo.watchVariety(id).first)!.photos.map((p) => p.bytes.toList()),
|
||||
[
|
||||
[1],
|
||||
[2],
|
||||
[3],
|
||||
],
|
||||
);
|
||||
|
||||
await repo.setPreferredPhoto(id, p3);
|
||||
|
||||
final photos = (await repo.watchVariety(id).first)!.photos;
|
||||
expect(photos.map((p) => p.bytes.toList()), [
|
||||
[3],
|
||||
[1],
|
||||
[2],
|
||||
]);
|
||||
});
|
||||
|
||||
test('setPreferredPhoto changes the inventory avatar to the cover', () async {
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
await repo.addPhoto(id, Uint8List.fromList([1]));
|
||||
final p2 = await repo.addPhoto(id, Uint8List.fromList([2]));
|
||||
|
||||
expect((await repo.watchInventory().first).single.photo!.toList(), [1]);
|
||||
|
||||
await repo.setPreferredPhoto(id, p2);
|
||||
expect((await repo.watchInventory().first).single.photo!.toList(), [2]);
|
||||
});
|
||||
|
||||
test('watchInventory avatar refreshes when a photo is added later', () async {
|
||||
final id = await repo.addQuickVariety(label: 'Maize');
|
||||
final queue = StreamQueue(repo.watchInventory());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue