|
1 | 1 | import 'package:appflowy/generated/flowy_svgs.g.dart'; |
| 2 | +import 'package:appflowy/generated/locale_keys.g.dart'; |
2 | 3 | import 'package:appflowy/mobile/application/page_style/document_page_style_bloc.dart'; |
3 | 4 | import 'package:appflowy/mobile/presentation/base/view_page/app_bar_buttons.dart'; |
4 | 5 | import 'package:appflowy/mobile/presentation/bottom_sheet/bottom_sheet_buttons.dart'; |
| 6 | +import 'package:appflowy/mobile/presentation/mobile_bottom_navigation_bar.dart'; |
5 | 7 | import 'package:appflowy/plugins/document/presentation/editor_page.dart'; |
6 | 8 | import 'package:appflowy/plugins/document/presentation/editor_plugins/cover/document_immersive_cover.dart'; |
| 9 | +import 'package:appflowy/plugins/document/presentation/editor_plugins/page_style/_page_style_icon.dart'; |
| 10 | +import 'package:appflowy/shared/icon_emoji_picker/recent_icons.dart'; |
| 11 | +import 'package:easy_localization/easy_localization.dart'; |
7 | 12 | import 'package:flutter/material.dart'; |
8 | 13 | import 'package:flutter_test/flutter_test.dart'; |
9 | 14 | import 'package:integration_test/integration_test.dart'; |
10 | 15 |
|
| 16 | +import '../../shared/emoji.dart'; |
11 | 17 | import '../../shared/util.dart'; |
12 | 18 |
|
13 | 19 | void main() { |
14 | | - IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 20 | + setUpAll(() { |
| 21 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 22 | + RecentIcons.enable = false; |
| 23 | + }); |
| 24 | + |
| 25 | + tearDownAll(() { |
| 26 | + RecentIcons.enable = true; |
| 27 | + }); |
15 | 28 |
|
16 | 29 | group('document page style:', () { |
17 | 30 | double getCurrentEditorFontSize() { |
@@ -114,5 +127,37 @@ void main() { |
114 | 127 | ); |
115 | 128 | expect(builtInCover, findsOneWidget); |
116 | 129 | }); |
| 130 | + |
| 131 | + testWidgets('page style icon', (tester) async { |
| 132 | + await tester.launchInAnonymousMode(); |
| 133 | + |
| 134 | + final createPageButton = |
| 135 | + find.byKey(BottomNavigationBarItemType.add.valueKey); |
| 136 | + await tester.tapButton(createPageButton); |
| 137 | + |
| 138 | + /// toggle the preset button |
| 139 | + await tester.tapSvgButton(FlowySvgs.m_layout_s); |
| 140 | + |
| 141 | + /// select document plugins emoji |
| 142 | + final pageStyleIcon = find.byType(PageStyleIcon); |
| 143 | + |
| 144 | + /// there should be none of emoji |
| 145 | + final noneText = find.text(LocaleKeys.pageStyle_none.tr()); |
| 146 | + expect(noneText, findsOneWidget); |
| 147 | + await tester.tapButton(pageStyleIcon); |
| 148 | + |
| 149 | + /// select an emoji |
| 150 | + const emoji = '😄'; |
| 151 | + await tester.tapEmoji(emoji); |
| 152 | + await tester.tapSvgButton(FlowySvgs.m_layout_s); |
| 153 | + expect(noneText, findsNothing); |
| 154 | + expect( |
| 155 | + find.descendant( |
| 156 | + of: pageStyleIcon, |
| 157 | + matching: find.text(emoji), |
| 158 | + ), |
| 159 | + findsOneWidget, |
| 160 | + ); |
| 161 | + }); |
117 | 162 | }); |
118 | 163 | } |
0 commit comments