dddf402d92
苹果 3.1.1:iOS 包不渲染在线购买卡与套餐价格链接;兑换券保留(3.1.3(b)), 新增「联系客服」卡(mailto:support@51yanmei.com,无购买引导字样)。 其余平台零改动;开关 hideExternalPurchaseUi 供设备上限弹窗等复用。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
78 lines
2.6 KiB
Dart
78 lines
2.6 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:jiu_client/core/auth/auth_state.dart';
|
|
import 'package:jiu_client/core/config/store_compliance.dart';
|
|
import 'package:jiu_client/core/theme/themes.dart';
|
|
import 'package:jiu_client/providers/license_provider.dart';
|
|
import 'package:jiu_client/screens/settings/license_panel.dart';
|
|
|
|
/// iOS App Store 合规形态(苹果 3.1.1):授权管理页隐藏一切外部购买 UI,
|
|
/// 补位中性「联系客服」卡;其余平台购买卡照旧、无客服卡。
|
|
|
|
class _FakeAuth extends AuthNotifier {
|
|
_FakeAuth(String role) {
|
|
state = AuthState(
|
|
user: AuthUser(
|
|
accessToken: 't',
|
|
refreshToken: 'r',
|
|
id: 1,
|
|
username: 'wang',
|
|
realName: '王经理',
|
|
shopNo: 'S001',
|
|
shopId: 1,
|
|
role: role),
|
|
);
|
|
}
|
|
}
|
|
|
|
class _FakeLicense extends LicenseNotifier {
|
|
@override
|
|
Future<LicenseInfo?> build() async => LicenseInfo(
|
|
id: 1,
|
|
type: 'annual',
|
|
isActive: true,
|
|
maxDevices: 2,
|
|
phase: 'active',
|
|
expiresAt: DateTime.now().add(const Duration(days: 100)),
|
|
);
|
|
}
|
|
|
|
Widget _panel({required String role}) => ProviderScope(
|
|
overrides: [
|
|
authStateProvider.overrideWith((ref) => _FakeAuth(role)),
|
|
licenseProvider.overrideWith(() => _FakeLicense()),
|
|
],
|
|
child: MaterialApp(
|
|
theme: buildTheme('a'),
|
|
home: const Scaffold(
|
|
body: SingleChildScrollView(child: LicensePanel()),
|
|
),
|
|
),
|
|
);
|
|
|
|
void main() {
|
|
tearDown(() => debugForceHideExternalPurchaseUi = null);
|
|
|
|
testWidgets('iOS 形态:购买卡与价格链接消失,出现联系客服卡', (tester) async {
|
|
debugForceHideExternalPurchaseUi = true;
|
|
await tester.pumpWidget(_panel(role: 'operator'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('在线购买 / 续费'), findsNothing);
|
|
expect(find.textContaining('查看套餐价格'), findsNothing);
|
|
expect(find.text('联系客服'), findsOneWidget);
|
|
expect(find.text(supportEmail), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('非 iOS:购买卡照旧,无联系客服卡', (tester) async {
|
|
debugForceHideExternalPurchaseUi = false;
|
|
await tester.pumpWidget(_panel(role: 'operator'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('在线购买 / 续费'), findsOneWidget);
|
|
expect(find.textContaining('查看套餐价格'), findsOneWidget);
|
|
expect(find.text('联系客服'), findsNothing);
|
|
});
|
|
}
|