feat(market): one-time community-rules gate before joining the market, publishing or messaging
This commit is contained in:
parent
a7e10eba7a
commit
5d25f65f76
7 changed files with 311 additions and 1 deletions
91
apps/app_seeds/test/ui/market_gate_test.dart
Normal file
91
apps/app_seeds/test/ui/market_gate_test.dart
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tane/i18n/strings.g.dart';
|
||||
import 'package:tane/services/onboarding_store.dart';
|
||||
import 'package:tane/ui/market_gate.dart';
|
||||
|
||||
import '../support/test_support.dart';
|
||||
|
||||
void main() {
|
||||
Widget host(OnboardingStore store, void Function(bool) onResult) =>
|
||||
TranslationProvider(
|
||||
child: MaterialApp(
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Builder(
|
||||
builder: (context) => Center(
|
||||
child: ElevatedButton(
|
||||
onPressed: () async {
|
||||
onResult(await ensureMarketRulesAccepted(context, store));
|
||||
},
|
||||
child: const Text('enter'),
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
testWidgets('accepting persists the flag and returns true', (tester) async {
|
||||
LocaleSettings.setLocaleSync(AppLocale.en);
|
||||
final store = OnboardingStore(InMemorySecretStore());
|
||||
bool? result;
|
||||
|
||||
await tester.pumpWidget(host(store, (r) => result = r));
|
||||
await tester.tap(find.text('enter'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(find.text('Before you join the market'), findsOneWidget);
|
||||
await tester.tap(find.text('I agree'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(result, isTrue);
|
||||
expect(await store.marketRulesAccepted(), isTrue);
|
||||
|
||||
// Second entry: already accepted, no sheet.
|
||||
result = null;
|
||||
await tester.tap(find.text('enter'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('Before you join the market'), findsNothing);
|
||||
expect(result, isTrue);
|
||||
});
|
||||
|
||||
testWidgets('declining returns false and persists nothing', (tester) async {
|
||||
LocaleSettings.setLocaleSync(AppLocale.en);
|
||||
final store = OnboardingStore(InMemorySecretStore());
|
||||
bool? result;
|
||||
|
||||
await tester.pumpWidget(host(store, (r) => result = r));
|
||||
await tester.tap(find.text('enter'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
await tester.tap(find.text('Not now'));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(result, isFalse);
|
||||
expect(await store.marketRulesAccepted(), isFalse);
|
||||
});
|
||||
|
||||
testWidgets('the sheet shows the three rules and the public note', (
|
||||
tester,
|
||||
) async {
|
||||
LocaleSettings.setLocaleSync(AppLocale.en);
|
||||
await tester.pumpWidget(
|
||||
TranslationProvider(
|
||||
child: const MaterialApp(
|
||||
localizationsDelegates: GlobalMaterialLocalizations.delegates,
|
||||
home: Scaffold(body: MarketGateSheet()),
|
||||
),
|
||||
),
|
||||
);
|
||||
await tester.pump();
|
||||
|
||||
expect(find.text('Be honest about the seeds you offer'), findsOneWidget);
|
||||
expect(
|
||||
find.text("Only share what you're allowed to share where you live"),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Treat people well — no spam, no abuse'), findsOneWidget);
|
||||
expect(find.textContaining('public'), findsWidgets);
|
||||
expect(find.text('Privacy & rules'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue