diff --git a/frontend/appflowy_flutter/integration_test/runner.dart b/frontend/appflowy_flutter/integration_test/runner.dart index 3a34c2c611..7336e9ed6c 100644 --- a/frontend/appflowy_flutter/integration_test/runner.dart +++ b/frontend/appflowy_flutter/integration_test/runner.dart @@ -22,6 +22,8 @@ import 'tabs_test.dart' as tabs_test; import 'hotkeys_test.dart' as hotkeys_test; import 'appearance_settings_test.dart' as appearance_test_runner; import 'auth/auth_test.dart' as auth_test_runner; +import 'settings/user_icon_test.dart' as user_icon_test; +import 'settings/user_language_test.dart' as user_language_test; /// The main task runner for all integration tests in AppFlowy. /// @@ -67,6 +69,10 @@ void main() { // Appearance integration test appearance_test_runner.main(); + // User settings + user_icon_test.main(); + user_language_test.main(); + if (isSupabaseEnabled) { auth_test_runner.main(); } diff --git a/frontend/appflowy_flutter/integration_test/settings/user_language_test.dart b/frontend/appflowy_flutter/integration_test/settings/user_language_test.dart new file mode 100644 index 0000000000..6bc4c07bb8 --- /dev/null +++ b/frontend/appflowy_flutter/integration_test/settings/user_language_test.dart @@ -0,0 +1,69 @@ +import 'dart:ui'; + +import 'package:appflowy/workspace/presentation/settings/widgets/settings_language_view.dart'; +import 'package:integration_test/integration_test.dart'; +import 'package:flutter_test/flutter_test.dart'; +import '../util/util.dart'; +import 'package:appflowy/workspace/application/settings/prelude.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('Settings: user language tests', () { + testWidgets('select language, language changed', (tester) async { + await tester.initializeAppFlowy(); + + await tester.tapGoButton(); + tester.expectToSeeHomePage(); + await tester.openSettings(); + + await tester.openSettingsPage(SettingsPage.language); + + final userLanguageFinder = find.descendant( + of: find.byType(SettingsLanguageView), + matching: find.byType(LanguageSelector), + ); + + // Grab current locale + LanguageSelector userLanguage = + tester.widget(userLanguageFinder); + Locale currentLocale = userLanguage.currentLocale; + + // Open language selector + await tester.tap(userLanguageFinder); + await tester.pumpAndSettle(); + + // Select first option that isn't default + await tester.tap(find.byType(LanguageItem).at(1)); + await tester.pumpAndSettle(); + + // Make sure the new locale is not the same as previous one + userLanguage = tester.widget(userLanguageFinder); + expect( + userLanguage.currentLocale, + isNot(equals(currentLocale)), + reason: "new language shouldn't equal the previous selected language", + ); + + // Update the current locale to a new one + currentLocale = userLanguage.currentLocale; + + // Tried the same flow for the second time + // Open language selector + await tester.tap(userLanguageFinder); + await tester.pumpAndSettle(); + + // Select second option that isn't default + await tester.tap(find.byType(LanguageItem).at(2)); + await tester.pumpAndSettle(); + + // Make sure the new locale is not the same as previous one + userLanguage = tester.widget(userLanguageFinder); + expect( + userLanguage.currentLocale, + isNot(equals(currentLocale)), + reason: "new language shouldn't equal the previous selected language", + ); + }); + }); +}