Merge branch 'spike/block2-derisking'

This commit is contained in:
vjrj 2026-07-10 11:56:56 +02:00
commit c18314d8c5
12 changed files with 92 additions and 108 deletions

View file

@ -48,7 +48,7 @@ class FakeOfferTransport implements OfferTransport {
Future<void> close() async {}
}
Widget _wrapBody(OffersCubit cubit) {
Widget _wrapBody(OffersCubit cubit, {String? selfPubkey}) {
LocaleSettings.setLocaleSync(AppLocale.en);
return TranslationProvider(
child: MaterialApp(
@ -62,7 +62,7 @@ Widget _wrapBody(OffersCubit cubit) {
home: Scaffold(
body: BlocProvider.value(
value: cubit,
child: MarketBody(onConfigure: () {}),
child: MarketBody(onConfigure: () {}, selfPubkey: selfPubkey),
),
),
),
@ -78,6 +78,27 @@ Offer _offer(String id, String summary, OfferType type) => Offer(
);
void main() {
testWidgets('shows a "You" badge on my own listing', (tester) async {
const me = 'aa';
final cubit = OffersCubit(FakeOfferTransport([
Offer(
id: '1',
authorPubkeyHex: me,
summary: 'Mine',
type: OfferType.gift,
approxGeohash: 'sp3e9',
),
]));
await tester.pumpWidget(_wrapBody(cubit, selfPubkey: me));
await cubit.discover('sp3');
await tester.pumpAndSettle();
expect(find.text('You'), findsOneWidget);
// My own listing offers no "Message yourself" button.
expect(find.text('Message'), findsNothing);
await cubit.close();
});
testWidgets('renders discovered offers with their type', (tester) async {
final cubit = OffersCubit(FakeOfferTransport([
_offer('1', 'Tomate rosa de Barbastro', OfferType.gift),