Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

fix: add simple test for l10n

Lucas.Xu8137769edd0b
diff --git a/frontend/app_flowy/packages/appflowy_editor/pubspec.yaml b/frontend/app_flowy/packages/appflowy_editor/pubspec.yaml
index af6c9c1f3f..0e48cc5fab 100644
--- a/frontend/app_flowy/packages/appflowy_editor/pubspec.yaml
+++ b/frontend/app_flowy/packages/appflowy_editor/pubspec.yaml
@@ -29,6 +29,9 @@ dev_dependencies:
sdk: flutter
flutter_lints: ^2.0.1
network_image_mock: ^2.1.1
+ flutter_localizations:
+ sdk: flutter
+
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
diff --git a/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart b/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart
index 9e7e0a0bb8..de69f95803 100644
--- a/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart
+++ b/frontend/app_flowy/packages/appflowy_editor/test/infra/test_editor.dart
@@ -3,6 +3,7 @@ import 'dart:collection';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
+import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_test/flutter_test.dart';
import 'test_raw_key_event.dart';
@@ -22,12 +23,18 @@ class EditorWidgetTester {
Selection? get documentSelection =>
_editorState.service.selectionService.currentSelection.value;
- Future<EditorWidgetTester> startTesting() async {
+ Future<EditorWidgetTester> startTesting({
+ Locale locale = const Locale('en'),
+ }) async {
final app = MaterialApp(
localizationsDelegates: const [
+ GlobalMaterialLocalizations.delegate,
+ GlobalCupertinoLocalizations.delegate,
+ GlobalWidgetsLocalizations.delegate,
AppFlowyEditorLocalizations.delegate,
],
supportedLocales: AppFlowyEditorLocalizations.delegate.supportedLocales,
+ locale: locale,
home: Scaffold(
body: AppFlowyEditor(
editorState: _editorState,
diff --git a/frontend/app_flowy/packages/appflowy_editor/test/l10n/l10n_test.dart b/frontend/app_flowy/packages/appflowy_editor/test/l10n/l10n_test.dart
new file mode 100644
index 0000000000..2e149d7b4f
--- /dev/null
+++ b/frontend/app_flowy/packages/appflowy_editor/test/l10n/l10n_test.dart
@@ -0,0 +1,19 @@
+import 'package:appflowy_editor/appflowy_editor.dart';
+import 'package:flutter_test/flutter_test.dart';
+import '../infra/test_editor.dart';
+
+void main() async {
+ setUpAll(() {
+ TestWidgetsFlutterBinding.ensureInitialized();
+ });
+
+ group('l10n.dart', () {
+ for (final locale
+ in AppFlowyEditorLocalizations.delegate.supportedLocales) {
+ testWidgets('test localization', (tester) async {
+ final editor = tester.editor..insertTextNode('');
+ await editor.startTesting(locale: locale);
+ });
+ }
+ });
+}