Skip to content

Commit

Permalink
fix: adapt integration test to new feature
Browse files Browse the repository at this point in the history
  • Loading branch information
zoli committed Nov 17, 2023
1 parent 3982185 commit 4c41ae1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import 'package:appflowy/workspace/application/settings/appearance/appearance_cubit.dart';
import 'package:appflowy_editor/appflowy_editor.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:integration_test/integration_test.dart';
Expand All @@ -10,7 +9,7 @@ void main() {

group('text direction', () {
testWidgets(
'''no text direction items will be displayed in the default/LTR mode,and three text direction items will be displayed in the RTL mode.''',
'''no text direction items will be displayed in the default/LTR mode, and three text direction items will be displayed when toggle is enabled.''',
(tester) async {
// combine the two tests into one to avoid the time-consuming process of initializing the app
await tester.initializeAppFlowy();
Expand All @@ -32,7 +31,7 @@ void main() {
'toolbar/text_direction_left',
'toolbar/text_direction_right',
];
// no text direction items in default/LTR mode
// no text direction items by default
var button = find.byWidgetPredicate(
(widget) =>
widget is SVGIconItemWidget &&
Expand All @@ -41,7 +40,7 @@ void main() {
expect(button, findsNothing);

// switch to the RTL mode
await tester.switchLayoutDirectionMode(LayoutDirection.rtlLayout);
await tester.toggleEnableRTLToolbarItems();

await tester.editor.tapLineOfEditorAt(0);
await tester.editor.updateSelection(selection);
Expand Down
29 changes: 6 additions & 23 deletions frontend/appflowy_flutter/integration_test/util/settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,32 +75,15 @@ extension AppFlowySettings on WidgetTester {
await pumpAndSettle();
}

// go to settings page and switch the layout direction
Future<void> switchLayoutDirectionMode(
LayoutDirection layoutDirection,
) async {
// go to settings page and toggle enable RTL toolbar items
Future<void> toggleEnableRTLToolbarItems() async {
await openSettings();
await openSettingsPage(SettingsPage.appearance);

final button = find.byKey(const ValueKey('layout_direction_option_button'));
expect(button, findsOneWidget);
await tapButton(button);

switch (layoutDirection) {
case LayoutDirection.ltrLayout:
final ltrButton = find.text(
LocaleKeys.settings_appearance_layoutDirection_ltr.tr(),
);
await tapButton(ltrButton);
break;
case LayoutDirection.rtlLayout:
final rtlButton = find.text(
LocaleKeys.settings_appearance_layoutDirection_rtl.tr(),
);
await tapButton(rtlButton);
break;
}

final switchButton = find.byKey(const ValueKey('enable_rtl_toolbar_items_switch'));
expect(switchButton, findsOneWidget);
await tapButton(switchButton);

// tap anywhere to close the settings page
await tapAt(Offset.zero);
await pumpAndSettle();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ class EnableRTLToolbarItemsSetting extends StatelessWidget {
label: LocaleKeys.settings_appearance_enableRTLToolbarItems.tr(),
trailing: [
Switch(
key: const ValueKey('enable_rtl_toolbar_items_switch'),
value: context.read<AppearanceSettingsCubit>().state.enableRtlToolbarItems,
splashRadius: 0,
activeColor: Theme.of(context).colorScheme.primary,
Expand Down

0 comments on commit 4c41ae1

Please sign in to comment.