The end-of-session dialog no longer carries a second "finish" button. "TERMINER TOUT" is now the only way out, and what it does with the target depends on the AI training setting: - setting on: the target is always sent, with a discreet reminder saying so; - setting off: a "CONTRIBUER À L'IA" switch (off by default, never remembered) decides whether the target is sent or kept on the device; - banned account or failed analysis: neither switch nor upload. Turning the switch on for the first time shows the full program disclaimer (what is sent, pseudonymity, banning rules); refusing leaves it off. That text moved to a shared showAiConsentDialog() so the settings switch and the session switch cannot drift apart, and a new is_ai_terms_accepted flag remembers the acceptance without silently enabling the global setting. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
63 lines
2.0 KiB
Dart
63 lines
2.0 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
|
|
|
import 'package:bully/services/wallet_identity_service.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
setUp(() => SharedPreferences.setMockInitialValues({}));
|
|
|
|
group('WalletIdentityService - consentement IA', () {
|
|
test('rien n\'est accepté ni activé à la première utilisation', () async {
|
|
final service = WalletIdentityService();
|
|
|
|
expect(await service.isUploadEnabled(), isFalse);
|
|
expect(await service.hasAcceptedAiTerms(), isFalse);
|
|
});
|
|
|
|
test('activer l\'option des Paramètres vaut acceptation des règles',
|
|
() async {
|
|
final service = WalletIdentityService();
|
|
|
|
await service.setUploadEnabled(true);
|
|
|
|
expect(await service.isUploadEnabled(), isTrue);
|
|
expect(await service.hasAcceptedAiTerms(), isTrue);
|
|
});
|
|
|
|
test('désactiver l\'option ne fait pas oublier les règles acceptées',
|
|
() async {
|
|
final service = WalletIdentityService();
|
|
|
|
await service.setUploadEnabled(true);
|
|
await service.setUploadEnabled(false);
|
|
|
|
expect(await service.isUploadEnabled(), isFalse);
|
|
// Le switch de fin de session ne redemandera donc pas l'avertissement.
|
|
expect(await service.hasAcceptedAiTerms(), isTrue);
|
|
});
|
|
|
|
test('accepter depuis le switch de fin de session n\'active pas l\'option '
|
|
'globale', () async {
|
|
final service = WalletIdentityService();
|
|
|
|
await service.setAiTermsAccepted(true);
|
|
|
|
expect(await service.hasAcceptedAiTerms(), isTrue);
|
|
expect(await service.isUploadEnabled(), isFalse);
|
|
});
|
|
|
|
test('un compte banni ne peut plus activer l\'envoi', () async {
|
|
final service = WalletIdentityService();
|
|
|
|
await service.setBanned(true, reason: 'Cibles non conformes');
|
|
await service.setUploadEnabled(true);
|
|
|
|
expect(await service.isBanned(), isTrue);
|
|
expect(await service.isUploadEnabled(), isFalse);
|
|
expect(await service.hasAcceptedAiTerms(), isFalse);
|
|
});
|
|
});
|
|
}
|