fix(account): 本地化网络异常文案
This commit is contained in:
1 parent
9b3ab9d5de
commit
27ab7cebfb
5 files changed
+90
-11
No files matched your search
@@ -101,6 +101,83 @@ void main() {
|
||||
|
||||
expect(find.byKey(const Key('account-export-content')), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('should_show_localized_network_copy_when_profile_load_fails', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeAccountRepository()..throwUnexpected = true;
|
||||
final auth = await _signedInAuth();
|
||||
await _pumpPage(
|
||||
tester,
|
||||
AccountProfilePage(),
|
||||
repository: repository,
|
||||
auth: auth,
|
||||
locale: const Locale('zh'),
|
||||
);
|
||||
final l10n = await AppLocalizations.delegate.load(const Locale('zh'));
|
||||
|
||||
expect(find.text(l10n.networkError), findsOneWidget);
|
||||
expect(find.text('accountProfileLoadFailed'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_show_localized_network_copy_when_profile_save_fails', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeAccountRepository();
|
||||
final auth = await _signedInAuth();
|
||||
await _pumpPage(
|
||||
tester,
|
||||
AccountProfilePage(),
|
||||
repository: repository,
|
||||
auth: auth,
|
||||
);
|
||||
repository.throwUnexpected = true;
|
||||
await tester.enterText(
|
||||
find.byKey(const Key('account-nickname')),
|
||||
'Nadia Baru',
|
||||
);
|
||||
await tester.tap(find.byKey(const Key('account-profile-save')));
|
||||
await tester.pumpAndSettle();
|
||||
final l10n = await AppLocalizations.delegate.load(const Locale('en'));
|
||||
|
||||
expect(find.text(l10n.networkError), findsOneWidget);
|
||||
expect(find.text('accountProfileSaveFailed'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_show_localized_network_copy_when_devices_fail', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeAccountRepository()..throwUnexpected = true;
|
||||
final auth = await _signedInAuth();
|
||||
await _pumpPage(
|
||||
tester,
|
||||
AccountDevicesPage(),
|
||||
repository: repository,
|
||||
auth: auth,
|
||||
locale: const Locale('id'),
|
||||
);
|
||||
final l10n = await AppLocalizations.delegate.load(const Locale('id'));
|
||||
|
||||
expect(find.text(l10n.networkError), findsOneWidget);
|
||||
expect(find.text('accountDevicesLoadFailed'), findsNothing);
|
||||
});
|
||||
|
||||
testWidgets('should_show_localized_network_copy_when_export_fails', (
|
||||
tester,
|
||||
) async {
|
||||
final repository = FakeAccountRepository()..throwUnexpected = true;
|
||||
final auth = await _signedInAuth();
|
||||
await _pumpPage(
|
||||
tester,
|
||||
AccountExportPage(),
|
||||
repository: repository,
|
||||
auth: auth,
|
||||
);
|
||||
final l10n = await AppLocalizations.delegate.load(const Locale('en'));
|
||||
|
||||
expect(find.text(l10n.networkError), findsOneWidget);
|
||||
expect(find.text('accountExportLoadFailed'), findsNothing);
|
||||
});
|
||||
}
|
||||
|
||||
Future<AuthController> _signedInAuth() async {
|
||||
@@ -124,6 +201,7 @@ Future<void> _pumpPage(
|
||||
Widget page, {
|
||||
required FakeAccountRepository repository,
|
||||
required AuthController auth,
|
||||
Locale locale = const Locale('en'),
|
||||
}) async {
|
||||
tester.view.physicalSize = const Size(390, 844);
|
||||
tester.view.devicePixelRatio = 1;
|
||||
@@ -136,7 +214,7 @@ Future<void> _pumpPage(
|
||||
ChangeNotifierProvider<AuthController>.value(value: auth),
|
||||
],
|
||||
child: MaterialApp(
|
||||
locale: const Locale('en'),
|
||||
locale: locale,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
home: Theme(data: ThemeData.dark(), child: page),
|
||||
|
||||
Reference in new issue
Block a user