feat(client): iOS 上架合规——首启隐私同意弹窗 + 注销账号入口
个保法/审核 5.1.1:移动端首启全屏隐私同意(链接隐私政策/用户协议, 同意持久化;不同意 Android 退出、iOS 留提示);我的页 iOS 形态新增 「注销账号」(sheet 说明 + 预填 mailto 至 support@51yanmei.com)。 关于页隐私政策/服务条款链接已有,桌面/Web 零改动。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:jiu_client/core/config/store_compliance.dart';
|
||||
import 'package:jiu_client/core/theme/themes.dart';
|
||||
import 'package:jiu_client/widgets/privacy_consent_gate.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
/// 首启隐私同意闸:移动端首启弹出并阻断交互,同意持久化后不再出现;
|
||||
/// 不同意(非 Android)留在弹层并给提示。
|
||||
|
||||
Widget _app() => MaterialApp(
|
||||
theme: buildTheme('a'),
|
||||
builder: (c, child) =>
|
||||
PrivacyConsentGate(child: child ?? const SizedBox.shrink()),
|
||||
home: const Scaffold(body: Text('APP')),
|
||||
);
|
||||
|
||||
void main() {
|
||||
tearDown(() => debugForcePrivacyConsentRequired = null);
|
||||
|
||||
testWidgets('首启弹出,同意后关闭并持久化', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
debugForcePrivacyConsentRequired = true;
|
||||
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('个人信息保护提示'), findsOneWidget);
|
||||
|
||||
await tester.tap(find.text('同意并继续'));
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('个人信息保护提示'), findsNothing);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
expect(prefs.getBool('privacy_consent_v1'), isTrue);
|
||||
});
|
||||
|
||||
testWidgets('已同意过:不再弹出', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({'privacy_consent_v1': true});
|
||||
debugForcePrivacyConsentRequired = true;
|
||||
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('个人信息保护提示'), findsNothing);
|
||||
expect(find.text('APP'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('不同意(非 Android):留在弹层并提示', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
debugForcePrivacyConsentRequired = true;
|
||||
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.pumpAndSettle();
|
||||
await tester.tap(find.text('不同意'));
|
||||
await tester.pump();
|
||||
expect(find.text('需同意后方可使用岩美酒库'), findsOneWidget);
|
||||
expect(find.text('个人信息保护提示'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('桌面/Web 形态:不弹', (tester) async {
|
||||
SharedPreferences.setMockInitialValues({});
|
||||
debugForcePrivacyConsentRequired = false;
|
||||
|
||||
await tester.pumpWidget(_app());
|
||||
await tester.pumpAndSettle();
|
||||
expect(find.text('个人信息保护提示'), findsNothing);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user