feat(block2): publish my seeds to the network (completes publish->discover)
The other half of the market: share your marked lots as offers. - VarietyRepository.shareableLots(): non-private lots WITH their id (stable, updatable offer id) + the variety label. Private lots never leave the device. - OffersCubit.publishLots(): maps each via OfferMapper and publishes, tagged with the coarse area + signed by the derived key; counts acceptances; no-op offline or with no area. - Market screen: a 'share my seeds' action (online only) — publishes, then re-discovers to show them; 'mark some seeds first' when nothing's shared. - i18n en/es/pt. 14 tests green (repo query, cubit publish, market UI); analyzer clean for new code.
This commit is contained in:
parent
cb5f55e146
commit
f8f73c4153
12 changed files with 284 additions and 5 deletions
43
apps/app_seeds/test/data/shareable_lots_test.dart
Normal file
43
apps/app_seeds/test/data/shareable_lots_test.dart
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/db/database.dart';
|
||||
import 'package:tane/db/enums.dart';
|
||||
|
||||
import '../support/test_support.dart';
|
||||
|
||||
void main() {
|
||||
late AppDatabase db;
|
||||
setUp(() => db = newTestDatabase());
|
||||
tearDown(() => db.close());
|
||||
|
||||
test('shareableLots returns non-private lots with their id and label',
|
||||
() async {
|
||||
final repo = newTestRepository(db);
|
||||
final varietyId = await repo.addQuickVariety(
|
||||
label: 'Tomate rosa',
|
||||
category: 'Solanaceae',
|
||||
);
|
||||
final sharedId = await repo.addLot(
|
||||
varietyId: varietyId,
|
||||
offerStatus: OfferStatus.exchange,
|
||||
);
|
||||
|
||||
final lots = await repo.shareableLots();
|
||||
final shared = lots.where((l) => l.lotId == sharedId).toList();
|
||||
expect(shared, hasLength(1));
|
||||
expect(shared.single.summary, 'Tomate rosa');
|
||||
expect(shared.single.offerStatus, OfferStatus.exchange);
|
||||
expect(shared.single.category, 'Solanaceae');
|
||||
});
|
||||
|
||||
test('private lots are never shareable', () async {
|
||||
final repo = newTestRepository(db);
|
||||
final varietyId = await repo.addQuickVariety(label: 'Pimiento');
|
||||
final privateId = await repo.addLot(
|
||||
varietyId: varietyId,
|
||||
offerStatus: OfferStatus.private,
|
||||
);
|
||||
|
||||
final lots = await repo.shareableLots();
|
||||
expect(lots.where((l) => l.lotId == privateId), isEmpty);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue