Files
jiu/client/test/license_panel_ios_test.dart
T

75 lines
2.3 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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):LicensePanel(授权信息 tab 内容,
/// 2026-07-10 起「在线购买续费」已独立为 LicenseScreen 的 tab2,见
/// license_screen_tabs_test.dartiOS 态补位中性「联系客服」卡,其余平台无。
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('联系客服'), findsOneWidget);
expect(find.text(supportEmail), findsOneWidget);
});
testWidgets('非 iOS:无联系客服卡', (tester) async {
debugForceHideExternalPurchaseUi = false;
await tester.pumpWidget(_panel(role: 'operator'));
await tester.pumpAndSettle();
expect(find.text('联系客服'), findsNothing);
});
}