| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-18 13:10:12 +01:00
										 |  |  | import 'package:flutter/gestures.dart'; | 
					
						
							|  |  |  | import 'package:flutter/material.dart'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  | import 'package:appflowy/generated/flowy_svgs.g.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | import 'package:appflowy/generated/locale_keys.g.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/plugins/database/application/calculations/calculation_type_ext.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-05 17:30:54 +08:00
										 |  |  | import 'package:appflowy/plugins/database/board/presentation/board_page.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/board/presentation/widgets/board_column_header.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/application/calendar_bloc.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/presentation/calendar_day.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/presentation/calendar_event_card.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/presentation/calendar_event_editor.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/presentation/calendar_page.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/calendar/presentation/toolbar/calendar_layout_setting.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/grid_page.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculate_cell.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/calculations/calculation_type_item.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/common/type_option_separator.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-05 17:30:54 +08:00
										 |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checkbox.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/checklist/checklist.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/select_option/option_list.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/select_option/select_option.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/choicechip/text.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/create_filter_list.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/disclosure_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/filter/filter_menu_item.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/footer/grid_footer.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/header/desktop_field_cell.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/row/row.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/create_sort_list.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/order_panel.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/sort_editor.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/sort/sort_menu.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/toolbar/filter_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/grid/presentation/widgets/toolbar/sort_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/tab_bar/desktop/tab_bar_add_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/tab_bar/desktop/tab_bar_header.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checkbox.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/checklist.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/date.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/number.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/select_option.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/text.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/timestamp.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell/editable_cell_skeleton/url.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-27 10:57:09 +08:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/checklist_cell_editor.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/checklist_progress_bar.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/date_editor.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/extension.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-29 11:54:42 +08:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_cell_editor.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-27 10:57:09 +08:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/cell_editor/select_option_text_field.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/database_layout_ext.dart'; | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/field/field_editor.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/field/field_type_list.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/field/type_option_editor/date/date_time_format.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/field/type_option_editor/number.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/row/accessory/cell_accessory.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-05 17:30:54 +08:00
										 |  |  | import 'package:appflowy/plugins/database/widgets/row/row_action.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/row/row_banner.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/row/row_detail.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/row/row_document.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/row/row_property.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/setting/database_layout_selector.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/setting/database_setting_action.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/setting/database_settings_list.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/setting/setting_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/plugins/database/widgets/setting/setting_property_list.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy/util/field_type_extension.dart'; | 
					
						
							| 
									
										
										
										
											2023-12-18 13:10:12 +01:00
										 |  |  | import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/clear_date_button.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/date_type_option_button.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | import 'package:appflowy/workspace/presentation/widgets/date_picker/widgets/reminder_selector.dart'; | 
					
						
							| 
									
										
										
										
											2023-10-02 10:52:22 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/widgets/dialogs.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/widgets/pop_up_action.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  | import 'package:appflowy/workspace/presentation/widgets/toggle/toggle.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:appflowy_backend/protobuf/flowy-database2/protobuf.dart'; | 
					
						
							| 
									
										
										
										
											2023-12-31 07:29:40 +08:00
										 |  |  | import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 |  |  | import 'package:appflowy_board/appflowy_board.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-01 20:29:49 +08:00
										 |  |  | import 'package:calendar_view/calendar_view.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | import 'package:easy_localization/easy_localization.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  | import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  | import 'package:flowy_infra_ui/style_widget/text_input.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | import 'package:flowy_infra_ui/widget/buttons/primary_button.dart'; | 
					
						
							|  |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-31 04:23:20 +02:00
										 |  |  | import 'package:path/path.dart' as p; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | // Non-exported member of the table_calendar library
 | 
					
						
							|  |  |  | import 'package:table_calendar/src/widgets/cell_content.dart'; | 
					
						
							| 
									
										
										
										
											2024-03-05 19:16:56 +01:00
										 |  |  | import 'package:table_calendar/table_calendar.dart'; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | import 'base.dart'; | 
					
						
							|  |  |  | import 'common_operations.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | import 'expectation.dart'; | 
					
						
							|  |  |  | import 'mock/mock_file_picker.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | extension AppFlowyDatabaseTest on WidgetTester { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   Future<void> openV020database() async { | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     final context = await initializeAppFlowy(); | 
					
						
							| 
									
										
										
										
											2024-04-11 16:33:28 +08:00
										 |  |  |     await tapAnonymousSignInButton(); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // expect to see a readme page
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |     expectToSeePageName(gettingStarted); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-31 19:06:01 +07:00
										 |  |  |     await tapAddViewButton(); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     await tapImportButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final testFileNames = ['v020.afdb']; | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     final paths = <String>[]; | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     for (final fileName in testFileNames) { | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       // Don't use the p.join to build the path that used in loadString. It
 | 
					
						
							|  |  |  |       // is not working on windows.
 | 
					
						
							|  |  |  |       final str = await rootBundle | 
					
						
							|  |  |  |           .loadString("assets/test/workspaces/database/$fileName"); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Write the content to the file.
 | 
					
						
							|  |  |  |       final path = p.join( | 
					
						
							|  |  |  |         context.applicationDataDirectory, | 
					
						
							|  |  |  |         fileName, | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       paths.add(path); | 
					
						
							|  |  |  |       File(path).writeAsStringSync(str); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     } | 
					
						
							|  |  |  |     // mock get files
 | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |     mockPickFilePaths( | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       paths: paths, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     await tapDatabaseRawDataButton(); | 
					
						
							| 
									
										
										
										
											2023-07-31 19:06:01 +07:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |     await openPage('v020', layout: ViewLayoutPB.Grid); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 |  |  |   Future<void> hoverOnFirstRowOfGrid([Future<void> Function()? onHover]) async { | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     final findRow = find.byType(GridRow); | 
					
						
							|  |  |  |     expect(findRow, findsWidgets); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final firstRow = findRow.first; | 
					
						
							| 
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 |  |  |     await hoverOnWidget(firstRow, onHover: onHover); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> editCell({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required FieldType fieldType, | 
					
						
							|  |  |  |     required String input, | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |     int cellIndex = 0, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |     final cell = cellFinder(rowIndex, fieldType, cellIndex: cellIndex); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect(cell, findsOneWidget); | 
					
						
							|  |  |  |     await enterText(cell, input); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |   Finder cellFinder(int rowIndex, FieldType fieldType, {int cellIndex = 0}) { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findRow = find.byType(GridRow, skipOffstage: false); | 
					
						
							|  |  |  |     final findCell = finderForFieldType(fieldType); | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |     return find | 
					
						
							|  |  |  |         .descendant( | 
					
						
							|  |  |  |           of: findRow.at(rowIndex), | 
					
						
							|  |  |  |           matching: findCell, | 
					
						
							|  |  |  |           skipOffstage: false, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .at(cellIndex); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapCheckboxCellInGrid({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final cell = cellFinder(rowIndex, FieldType.Checkbox); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: cell, | 
					
						
							|  |  |  |       matching: find.byType(FlowyIconButton), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect(cell, findsOneWidget); | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> assertCheckboxCell({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required bool isSelected, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final cell = cellFinder(rowIndex, FieldType.Checkbox); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     final finder = isSelected | 
					
						
							|  |  |  |         ? find.byWidgetPredicate( | 
					
						
							|  |  |  |             (widget) => | 
					
						
							|  |  |  |                 widget is FlowySvg && widget.svg == FlowySvgs.check_filled_s, | 
					
						
							|  |  |  |           ) | 
					
						
							|  |  |  |         : find.byWidgetPredicate( | 
					
						
							|  |  |  |             (widget) => widget is FlowySvg && widget.svg == FlowySvgs.uncheck_s, | 
					
						
							|  |  |  |           ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     expect( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: cell, | 
					
						
							|  |  |  |         matching: finder, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       findsOneWidget, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapCellInGrid({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required FieldType fieldType, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final cell = cellFinder(rowIndex, fieldType); | 
					
						
							|  |  |  |     expect(cell, findsOneWidget); | 
					
						
							| 
									
										
										
										
											2024-01-25 16:37:36 +01:00
										 |  |  |     await tapButton(cell); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |   /// The [fieldName] must be unique in the grid.
 | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   void assertCellContent({ | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required FieldType fieldType, | 
					
						
							|  |  |  |     required String content, | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |     int cellIndex = 0, | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   }) { | 
					
						
							| 
									
										
										
										
											2023-06-22 20:16:31 +08:00
										 |  |  |     final findCell = cellFinder(rowIndex, fieldType, cellIndex: cellIndex); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findContent = find.descendant( | 
					
						
							|  |  |  |       of: findCell, | 
					
						
							|  |  |  |       matching: find.text(content), | 
					
						
							|  |  |  |       skipOffstage: false, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     expect(findContent, findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   Future<void> assertSingleSelectOption({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required String content, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final findCell = cellFinder(rowIndex, FieldType.SingleSelect); | 
					
						
							|  |  |  |     if (content.isNotEmpty) { | 
					
						
							|  |  |  |       final finder = find.descendant( | 
					
						
							|  |  |  |         of: findCell, | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-12-02 02:03:30 +08:00
										 |  |  |           (widget) => | 
					
						
							|  |  |  |               widget is SelectOptionTag && | 
					
						
							|  |  |  |               (widget.name == content || widget.option?.name == content), | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |         ), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       expect(finder, findsOneWidget); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> assertMultiSelectOption({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required List<String> contents, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final findCell = cellFinder(rowIndex, FieldType.MultiSelect); | 
					
						
							|  |  |  |     for (final content in contents) { | 
					
						
							|  |  |  |       if (content.isNotEmpty) { | 
					
						
							|  |  |  |         final finder = find.descendant( | 
					
						
							|  |  |  |           of: findCell, | 
					
						
							|  |  |  |           matching: find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-12-02 02:03:30 +08:00
										 |  |  |             (widget) => | 
					
						
							|  |  |  |                 widget is SelectOptionTag && | 
					
						
							|  |  |  |                 (widget.name == content || widget.option?.name == content), | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |           ), | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |         expect(finder, findsOneWidget); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |   /// null percent means no progress bar should be found
 | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   void assertChecklistCellInGrid({ | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     required int rowIndex, | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     required double? percent, | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   }) { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findCell = cellFinder(rowIndex, FieldType.Checklist); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (percent == null) { | 
					
						
							|  |  |  |       final finder = find.descendant( | 
					
						
							|  |  |  |         of: findCell, | 
					
						
							|  |  |  |         matching: find.byType(ChecklistProgressBar), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       expect(finder, findsNothing); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       final finder = find.descendant( | 
					
						
							|  |  |  |         of: findCell, | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |           (widget) => | 
					
						
							|  |  |  |               widget is ChecklistProgressBar && widget.percent == percent, | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |         ), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |       expect(finder, findsOneWidget); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> selectDay({ | 
					
						
							|  |  |  |     required int content, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final findCalendar = find.byType(TableCalendar); | 
					
						
							|  |  |  |     final findDay = find.text(content.toString()); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final finder = find.descendant( | 
					
						
							|  |  |  |       of: findCalendar, | 
					
						
							|  |  |  |       matching: findDay, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-28 22:11:50 +08:00
										 |  |  |     // if the day is very near the beginning or the end of the month,
 | 
					
						
							|  |  |  |     // it may overlap with the same day in the next or previous month,
 | 
					
						
							|  |  |  |     // respectively because it was spilling over. This will lead to 2
 | 
					
						
							|  |  |  |     // widgets being found and thus cannot be tapped correctly.
 | 
					
						
							|  |  |  |     if (content < 15) { | 
					
						
							|  |  |  |       // e.g., Jan 2 instead of Feb 2
 | 
					
						
							|  |  |  |       await tapButton(finder.first); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       // e.g. Jun 28 instead of May 28
 | 
					
						
							|  |  |  |       await tapButton(finder.last); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |   Future<void> toggleIncludeTime() async { | 
					
						
							| 
									
										
										
										
											2023-09-19 09:58:15 +08:00
										 |  |  |     final findDateEditor = find.byType(IncludeTimeButton); | 
					
						
							|  |  |  |     final findToggle = find.byType(Toggle); | 
					
						
							|  |  |  |     final finder = find.descendant( | 
					
						
							|  |  |  |       of: findDateEditor, | 
					
						
							|  |  |  |       matching: findToggle, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> selectReminderOption(ReminderOption option) async { | 
					
						
							| 
									
										
										
										
											2024-01-31 14:17:36 +01:00
										 |  |  |     await tapButton(find.byType(ReminderSelector)); | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     final finder = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(FlowyButton), | 
					
						
							| 
									
										
										
										
											2024-01-31 14:17:36 +01:00
										 |  |  |       matching: find.textContaining(option.label), | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-31 14:17:36 +01:00
										 |  |  |   Future<bool> selectLastDateInPicker() async { | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  |     final finder = find.byType(CellContent).last; | 
					
						
							| 
									
										
										
										
											2024-01-31 14:17:36 +01:00
										 |  |  |     final w = widget(finder) as CellContent; | 
					
						
							| 
									
										
										
										
											2024-01-24 15:15:57 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							| 
									
										
										
										
											2024-01-31 14:17:36 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     return w.isToday; | 
					
						
							| 
									
										
										
										
											2023-09-19 09:58:15 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   Future<void> tapChangeDateTimeFormatButton() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(DateTypeOptionButton)); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   Future<void> changeDateFormat() async { | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |     final findDateFormatButton = find.byType(DateFormatButton); | 
					
						
							|  |  |  |     await tapButton(findDateFormatButton); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findNewDateFormat = find.text("Day/Month/Year"); | 
					
						
							|  |  |  |     await tapButton(findNewDateFormat); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> changeTimeFormat() async { | 
					
						
							|  |  |  |     final findDateFormatButton = find.byType(TimeFormatButton); | 
					
						
							|  |  |  |     await tapButton(findDateFormatButton); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findNewDateFormat = find.text("12 hour"); | 
					
						
							|  |  |  |     await tapButton(findNewDateFormat); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-31 04:23:20 +02:00
										 |  |  |   Future<void> clearDate() async { | 
					
						
							|  |  |  |     final findDateEditor = find.byType(DateCellEditor); | 
					
						
							|  |  |  |     final findClearButton = find.byType(ClearDateButton); | 
					
						
							|  |  |  |     final finder = find.descendant( | 
					
						
							|  |  |  |       of: findDateEditor, | 
					
						
							|  |  |  |       matching: findClearButton, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |   Future<void> tapSelectOptionCellInGrid({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required FieldType fieldType, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     assert( | 
					
						
							|  |  |  |       fieldType == FieldType.SingleSelect || fieldType == FieldType.MultiSelect, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findRow = find.byType(GridRow); | 
					
						
							|  |  |  |     final findCell = finderForFieldType(fieldType); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final cell = find.descendant( | 
					
						
							|  |  |  |       of: findRow.at(rowIndex), | 
					
						
							|  |  |  |       matching: findCell, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(cell); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// The [SelectOptionCellEditor] must be opened first.
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> createOption({required String name}) async { | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |     final findEditor = find.byType(SelectOptionCellEditor); | 
					
						
							|  |  |  |     expect(findEditor, findsOneWidget); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findTextField = find.byType(SelectOptionTextField); | 
					
						
							|  |  |  |     expect(findTextField, findsOneWidget); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText(findTextField, name); | 
					
						
							|  |  |  |     await pump(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await testTextInput.receiveAction(TextInputAction.done); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> selectOption({required String name}) async { | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |     final option = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is SelectOptionTagCell && widget.option.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(option); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |   Future<void> findSelectOptionWithNameInGrid({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required String name, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final findRow = find.byType(GridRow); | 
					
						
							|  |  |  |     final option = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-12-02 02:03:30 +08:00
										 |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is SelectOptionTag && | 
					
						
							|  |  |  |           (widget.name == name || widget.option?.name == name), | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     final cell = find.descendant(of: findRow.at(rowIndex), matching: option); | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |     expect(cell, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |   Future<void> assertNumberOfSelectedOptionsInGrid({ | 
					
						
							|  |  |  |     required int rowIndex, | 
					
						
							|  |  |  |     required Matcher matcher, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final findRow = find.byType(GridRow); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final options = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is SelectOptionTag, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     final cell = find.descendant(of: findRow.at(rowIndex), matching: options); | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |     expect(cell, matcher); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |   Future<void> tapChecklistCellInGrid({required int rowIndex}) async { | 
					
						
							|  |  |  |     final findRow = find.byType(GridRow); | 
					
						
							|  |  |  |     final findCell = finderForFieldType(FieldType.Checklist); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     final cell = find.descendant(of: findRow.at(rowIndex), matching: findCell); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     await tapButton(cell); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertChecklistEditorVisible({required bool visible}) { | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     final editor = find.byType(ChecklistCellEditor); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     if (visible) { | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       return expect(editor, findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     expect(editor, findsNothing); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> createNewChecklistTask({ | 
					
						
							|  |  |  |     required String name, | 
					
						
							|  |  |  |     enter = false, | 
					
						
							|  |  |  |     button = false, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     assert(!(enter && button)); | 
					
						
							|  |  |  |     final textField = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(NewTaskItem), | 
					
						
							|  |  |  |       matching: find.byType(TextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText(textField, name); | 
					
						
							| 
									
										
										
										
											2023-09-22 09:33:24 +08:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     if (enter) { | 
					
						
							|  |  |  |       await testTextInput.receiveAction(TextInputAction.done); | 
					
						
							| 
									
										
										
										
											2023-09-22 09:33:24 +08:00
										 |  |  |       await pumpAndSettle(); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     } else { | 
					
						
							|  |  |  |       await tapButton( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(NewTaskItem), | 
					
						
							|  |  |  |           matching: find.byType(FlowyTextButton), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertChecklistTaskInEditor({ | 
					
						
							|  |  |  |     required int index, | 
					
						
							|  |  |  |     required String name, | 
					
						
							|  |  |  |     required bool isChecked, | 
					
						
							|  |  |  |   }) { | 
					
						
							|  |  |  |     final task = find.byType(ChecklistItem).at(index); | 
					
						
							|  |  |  |     final widget = this.widget<ChecklistItem>(task); | 
					
						
							|  |  |  |     assert( | 
					
						
							| 
									
										
										
										
											2023-10-24 10:15:28 +08:00
										 |  |  |       widget.task.data.name == name && widget.task.isSelected == isChecked, | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> renameChecklistTask({ | 
					
						
							|  |  |  |     required int index, | 
					
						
							|  |  |  |     required String name, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final textField = find | 
					
						
							|  |  |  |         .descendant( | 
					
						
							|  |  |  |           of: find.byType(ChecklistItem), | 
					
						
							|  |  |  |           matching: find.byType(TextField), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .at(index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText(textField, name); | 
					
						
							|  |  |  |     await testTextInput.receiveAction(TextInputAction.done); | 
					
						
							| 
									
										
										
										
											2023-09-22 09:33:24 +08:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							| 
									
										
										
										
											2023-09-13 20:44:04 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> checkChecklistTask({required int index}) async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(ChecklistItem).at(index), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => widget is FlowySvg && widget.svg == FlowySvgs.uncheck_s, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> deleteChecklistTask({required int index}) async { | 
					
						
							|  |  |  |     final task = find.byType(ChecklistItem).at(index); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await startGesture(getCenter(task), kind: PointerDeviceKind.mouse); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final button = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is FlowySvg && widget.svg == FlowySvgs.delete_s, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> openFirstRowDetailPage() async { | 
					
						
							|  |  |  |     await hoverOnFirstRowOfGrid(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final expandButton = find.byType(PrimaryCellAccessory); | 
					
						
							|  |  |  |     expect(expandButton, findsOneWidget); | 
					
						
							|  |  |  |     await tapButton(expandButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   void assertRowDetailPageOpened() async { | 
					
						
							|  |  |  |     final findRowDetailPage = find.byType(RowDetailPage); | 
					
						
							|  |  |  |     expect(findRowDetailPage, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> dismissRowDetailPage() async { | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     // use tap empty area instead of clicking ESC to dismiss the row detail page
 | 
					
						
							|  |  |  |     // sometimes, the ESC key is not working.
 | 
					
						
							|  |  |  |     await simulateKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     final findRowDetailPage = find.byType(RowDetailPage); | 
					
						
							|  |  |  |     if (findRowDetailPage.evaluate().isNotEmpty) { | 
					
						
							|  |  |  |       await tapAt(const Offset(0, 0)); | 
					
						
							|  |  |  |       await pumpAndSettle(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> hoverRowBanner() async { | 
					
						
							|  |  |  |     final banner = find.byType(RowBanner); | 
					
						
							|  |  |  |     expect(banner, findsOneWidget); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     await startGesture(getCenter(banner), kind: PointerDeviceKind.mouse); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> openEmojiPicker() async => | 
					
						
							|  |  |  |       tapButton(find.byType(AddEmojiButton)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   Future<void> tapDateCellInRowDetailPage() async { | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     final findDateCell = find.byType(EditableDateCell); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     await tapButton(findDateCell); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |   Future<void> tapGridFieldWithNameInRowDetailPage(String name) async { | 
					
						
							|  |  |  |     final fields = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is FieldCellButton && widget.field.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     final field = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(RowDetailPage), | 
					
						
							|  |  |  |       matching: fields, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 19:10:08 +08:00
										 |  |  |   Future<TestGesture> hoverOnFieldInRowDetail({required int index}) async { | 
					
						
							|  |  |  |     final fieldButtons = find.byType(FieldCellButton); | 
					
						
							|  |  |  |     final button = find | 
					
						
							|  |  |  |         .descendant(of: find.byType(RowDetailPage), matching: fieldButtons) | 
					
						
							|  |  |  |         .at(index); | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     return startGesture(getCenter(button), kind: PointerDeviceKind.mouse); | 
					
						
							| 
									
										
										
										
											2023-09-13 19:10:08 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> reorderFieldInRowDetail({required double offset}) async { | 
					
						
							|  |  |  |     final thumb = find | 
					
						
							|  |  |  |         .byWidgetPredicate( | 
					
						
							|  |  |  |           (widget) => widget is ReorderableDragStartListener && widget.enabled, | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .first; | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     await drag(thumb, Offset(0, offset), kind: PointerDeviceKind.mouse); | 
					
						
							| 
									
										
										
										
											2023-09-13 19:10:08 +08:00
										 |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-02 10:52:22 +08:00
										 |  |  |   void assertToggleShowHiddenFieldsVisibility(bool shown) { | 
					
						
							|  |  |  |     final button = find.byType(ToggleHiddenFieldsVisibilityButton); | 
					
						
							|  |  |  |     if (shown) { | 
					
						
							|  |  |  |       expect(button, findsOneWidget); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       expect(button, findsNothing); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> toggleShowHiddenFields() async { | 
					
						
							|  |  |  |     final button = find.byType(ToggleHiddenFieldsVisibilityButton); | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapDeletePropertyInFieldEditor() async { | 
					
						
							| 
									
										
										
										
											2023-11-23 16:43:29 +08:00
										 |  |  |     final deleteButton = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is FieldActionCell && w.action == FieldAction.delete, | 
					
						
							| 
									
										
										
										
											2023-11-23 16:43:29 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-10-02 10:52:22 +08:00
										 |  |  |     await tapButton(deleteButton); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final confirmButton = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(NavigatorAlertDialog), | 
					
						
							|  |  |  |       matching: find.byType(PrimaryTextButton), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(confirmButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> scrollRowDetailByOffset(Offset offset) async { | 
					
						
							|  |  |  |     await drag(find.byType(RowDetailPage), offset); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> scrollToRight(Finder find) async { | 
					
						
							|  |  |  |     final size = getSize(find); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     await drag(find, Offset(-size.width, 0), warnIfMissed: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await pumpAndSettle(const Duration(milliseconds: 500)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapNewPropertyButton() async { | 
					
						
							|  |  |  |     await tapButtonWithName(LocaleKeys.grid_field_newProperty.tr()); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapGridFieldWithName(String name) async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is FieldCellButton && widget.field.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-03 17:52:38 +01:00
										 |  |  |   Future<void> changeFieldTypeOfFieldWithName( | 
					
						
							|  |  |  |     String name, | 
					
						
							| 
									
										
										
										
											2024-05-20 12:49:58 +03:30
										 |  |  |     FieldType type, { | 
					
						
							|  |  |  |     ViewLayoutPB layout = ViewLayoutPB.Grid, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2024-02-03 17:52:38 +01:00
										 |  |  |     await tapGridFieldWithName(name); | 
					
						
							| 
									
										
										
										
											2024-05-20 12:49:58 +03:30
										 |  |  |     if (layout == ViewLayoutPB.Grid) { | 
					
						
							|  |  |  |       await tapEditFieldButton(); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-02-03 17:52:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     await tapSwitchFieldTypeButton(); | 
					
						
							|  |  |  |     await selectFieldType(type); | 
					
						
							|  |  |  |     await dismissFieldEditor(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> changeCalculateAtIndex(int index, CalculationType type) async { | 
					
						
							|  |  |  |     await tap(find.byType(CalculateCell).at(index)); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tap( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: find.byType(CalculationTypeItem), | 
					
						
							|  |  |  |         matching: find.text(type.label), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   /// Should call [tapGridFieldWithName] first.
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   Future<void> tapEditFieldButton() async { | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await tapButtonWithName(LocaleKeys.grid_field_editProperty.tr()); | 
					
						
							|  |  |  |     await pumpAndSettle(const Duration(milliseconds: 200)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Should call [tapGridFieldWithName] first.
 | 
					
						
							|  |  |  |   Future<void> tapDeletePropertyButton() async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is FieldActionCell && w.action == FieldAction.delete, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   /// A SimpleDialog must be shown first, e.g. when deleting a field.
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> tapDialogOkButton() async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is PrimaryTextButton && w.label == LocaleKeys.button_ok.tr(), | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Should call [tapGridFieldWithName] first.
 | 
					
						
							|  |  |  |   Future<void> tapDuplicatePropertyButton() async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is FieldActionCell && w.action == FieldAction.duplicate, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-29 04:42:53 +08:00
										 |  |  |   Future<void> tapInsertFieldButton({ | 
					
						
							|  |  |  |     required bool left, | 
					
						
							|  |  |  |     required String name, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FieldActionCell && | 
					
						
							|  |  |  |           (left && widget.action == FieldAction.insertLeft || | 
					
						
							|  |  |  |               !left && widget.action == FieldAction.insertRight), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |     await renameField(name); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   /// Should call [tapGridFieldWithName] first.
 | 
					
						
							|  |  |  |   Future<void> tapHidePropertyButton() async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is FieldActionCell && w.action == FieldAction.toggleVisibility, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |   Future<void> tapHidePropertyButtonInFieldEditor() async { | 
					
						
							| 
									
										
										
										
											2023-11-23 16:43:29 +08:00
										 |  |  |     final button = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is FieldActionCell && w.action == FieldAction.toggleVisibility, | 
					
						
							| 
									
										
										
										
											2023-11-23 16:43:29 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapRowDetailPageRowActionButton() async => | 
					
						
							|  |  |  |       tapButton(find.byType(RowActionButton)); | 
					
						
							| 
									
										
										
										
											2023-09-13 19:10:08 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapRowDetailPageCreatePropertyButton() async => | 
					
						
							|  |  |  |       tapButton(find.byType(CreateRowFieldButton)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapRowDetailPageDeleteRowButton() async => | 
					
						
							|  |  |  |       tapButton(find.byType(RowDetailPageDeleteButton)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapRowDetailPageDuplicateRowButton() async => | 
					
						
							|  |  |  |       tapButton(find.byType(RowDetailPageDuplicateButton)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapSwitchFieldTypeButton() async => | 
					
						
							|  |  |  |       tapButton(find.byType(SwitchFieldButton)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapEscButton() async => sendKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   /// Must call [tapSwitchFieldTypeButton] first.
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> selectFieldType(FieldType fieldType) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final fieldTypeCell = find.byType(FieldTypeCell); | 
					
						
							|  |  |  |     final fieldTypeButton = find.descendant( | 
					
						
							|  |  |  |       of: fieldTypeCell, | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-01-31 21:15:38 +08:00
										 |  |  |         (widget) => widget is FlowyText && widget.text == fieldType.i18n, | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |       ), | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(fieldTypeButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   // Use in edit mode of FieldEditor
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   void expectEmptyTypeOptionEditor() => expect( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(FieldTypeOptionEditor), | 
					
						
							|  |  |  |           matching: find.byType(TypeOptionSeparator), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         findsNothing, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   /// Each field has its own cell, so we can find the corresponding cell by
 | 
					
						
							|  |  |  |   /// the field type after create a new field.
 | 
					
						
							|  |  |  |   Future<void> findCellByFieldType(FieldType fieldType) async { | 
					
						
							|  |  |  |     final finder = finderForFieldType(fieldType); | 
					
						
							|  |  |  |     expect(finder, findsWidgets); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> assertNumberOfRowsInGridPage(int num) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     expect( | 
					
						
							|  |  |  |       find.byType(GridRow, skipOffstage: false), | 
					
						
							|  |  |  |       findsNWidgets(num), | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> assertDocumentExistInRowDetailPage() async { | 
					
						
							|  |  |  |     expect(find.byType(RowDocument), findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Check the field type of the [FieldCellButton] is the same as the name.
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> assertFieldTypeWithFieldName(String name, FieldType type) async { | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FieldCellButton && | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |           widget.field.fieldType == type && | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |           widget.field.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     expect(field, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-13 19:10:08 +08:00
										 |  |  |   void assertFirstFieldInRowDetailByType(FieldType fieldType) { | 
					
						
							|  |  |  |     final firstField = find | 
					
						
							|  |  |  |         .descendant( | 
					
						
							|  |  |  |           of: find.byType(RowDetailPage), | 
					
						
							|  |  |  |           matching: find.byType(FieldCellButton), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .first; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final widget = this.widget<FieldCellButton>(firstField); | 
					
						
							|  |  |  |     expect(widget.field.fieldType, fieldType); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   void findFieldWithName(String name) { | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is FieldCellButton && widget.field.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     expect(field, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |   void noFieldWithName(String name) { | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is FieldCellButton && widget.field.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     expect(field, findsNothing); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> renameField(String newName) async { | 
					
						
							|  |  |  |     final textField = find.byType(FieldNameTextField); | 
					
						
							|  |  |  |     expect(textField, findsOneWidget); | 
					
						
							|  |  |  |     await enterText(textField, newName); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> dismissFieldEditor() async { | 
					
						
							|  |  |  |     await sendKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     await pumpAndSettle(const Duration(milliseconds: 200)); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> findDateEditor(dynamic matcher) async { | 
					
						
							|  |  |  |     final finder = find.byType(DateCellEditor); | 
					
						
							|  |  |  |     expect(finder, matcher); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |   Future<void> findSelectOptionEditor(dynamic matcher) async { | 
					
						
							|  |  |  |     final finder = find.byType(SelectOptionCellEditor); | 
					
						
							|  |  |  |     expect(finder, matcher); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 22:53:49 +08:00
										 |  |  |   Future<void> dismissCellEditor() async { | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |     await sendKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> tapCreateRowButtonInGrid() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(GridAddRowButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapCreateRowButtonInRowMenuOfGrid() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(InsertRowButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapRowMenuButtonInGrid() async { | 
					
						
							| 
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 |  |  |     expect(find.byType(RowMenuButton), findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await tapButton(find.byType(RowMenuButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Should call [tapRowMenuButtonInGrid] first.
 | 
					
						
							|  |  |  |   Future<void> tapDeleteOnRowMenu() async { | 
					
						
							| 
									
										
										
										
											2024-06-17 14:30:19 +02:00
										 |  |  |     expect(find.text(LocaleKeys.grid_row_delete.tr()), findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await tapButtonWithName(LocaleKeys.grid_row_delete.tr()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-20 12:49:58 +03:30
										 |  |  |   Future<void> createField( | 
					
						
							|  |  |  |     FieldType fieldType, | 
					
						
							|  |  |  |     String name, { | 
					
						
							|  |  |  |     ViewLayoutPB layout = ViewLayoutPB.Grid, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     if (layout == ViewLayoutPB.Grid) { | 
					
						
							|  |  |  |       await scrollToRight(find.byType(GridPage)); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await tapNewPropertyButton(); | 
					
						
							|  |  |  |     await renameField(name); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     await tapSwitchFieldTypeButton(); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await selectFieldType(fieldType); | 
					
						
							|  |  |  |     await dismissFieldEditor(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapDatabaseSettingButton() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(SettingButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   Future<void> tapDatabaseFilterButton() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(FilterButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  |   Future<void> tapDatabaseSortButton() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(SortButton)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapCreateFilterByFieldType(FieldType type, String title) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findFilter = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is GridFilterPropertyCell && | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |           widget.fieldInfo.fieldType == type && | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |           widget.fieldInfo.name == title, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(findFilter); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapFilterButtonInGrid(String name) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findFilter = find.byType(FilterMenuItem); | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     final button = find.descendant(of: findFilter, matching: find.text(name)); | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapCreateSortByFieldType(FieldType type, String title) async { | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  |     final findSort = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is GridSortPropertyCell && | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |           widget.fieldInfo.fieldType == type && | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  |           widget.fieldInfo.name == title, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(findSort); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Must call [tapSortMenuInSettingBar] first.
 | 
					
						
							|  |  |  |   Future<void> tapCreateSortByFieldTypeInSortMenu( | 
					
						
							|  |  |  |     FieldType fieldType, | 
					
						
							|  |  |  |     String title, | 
					
						
							|  |  |  |   ) async { | 
					
						
							|  |  |  |     await tapButton(find.byType(DatabaseAddSortButton)); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findSort = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is GridSortPropertyCell && | 
					
						
							|  |  |  |           widget.fieldInfo.fieldType == fieldType && | 
					
						
							|  |  |  |           widget.fieldInfo.name == title, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(findSort); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapSortMenuInSettingBar() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(SortMenu)); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Must call [tapSortMenuInSettingBar] first.
 | 
					
						
							|  |  |  |   Future<void> tapSortButtonByName(String name) async { | 
					
						
							|  |  |  |     final findSortItem = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is DatabaseSortItem && widget.sortInfo.fieldInfo.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(findSortItem); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-02-05 13:52:59 +08:00
										 |  |  |   /// Must call [tapSortMenuInSettingBar] first.
 | 
					
						
							|  |  |  |   Future<void> reorderSort( | 
					
						
							|  |  |  |     (FieldType, String) from, | 
					
						
							|  |  |  |     (FieldType, String) to, | 
					
						
							|  |  |  |   ) async { | 
					
						
							|  |  |  |     final fromSortItem = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is DatabaseSortItem && | 
					
						
							|  |  |  |           widget.sortInfo.fieldInfo.fieldType == from.$1 && | 
					
						
							|  |  |  |           widget.sortInfo.fieldInfo.name == from.$2, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     final toSortItem = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is DatabaseSortItem && | 
					
						
							|  |  |  |           widget.sortInfo.fieldInfo.fieldType == to.$1 && | 
					
						
							|  |  |  |           widget.sortInfo.fieldInfo.name == to.$2, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     final dragElement = find.descendant( | 
					
						
							|  |  |  |       of: fromSortItem, | 
					
						
							|  |  |  |       matching: find.byType(ReorderableDragStartListener), | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     await drag(dragElement, getCenter(toSortItem) - getCenter(fromSortItem)); | 
					
						
							| 
									
										
										
										
											2024-02-05 13:52:59 +08:00
										 |  |  |     await pumpAndSettle(const Duration(milliseconds: 200)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  |   /// Must call [tapSortButtonByName] first.
 | 
					
						
							|  |  |  |   Future<void> tapSortByDescending() async { | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: find.byType(OrderPannelItem), | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |           (widget) => | 
					
						
							|  |  |  |               widget is FlowyText && | 
					
						
							|  |  |  |               widget.text == LocaleKeys.grid_sort_descending.tr(), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await sendKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Must call [tapSortMenuInSettingBar] first.
 | 
					
						
							|  |  |  |   Future<void> tapAllSortButton() async { | 
					
						
							| 
									
										
										
										
											2024-02-24 22:55:22 +08:00
										 |  |  |     await tapButton(find.byType(DeleteAllSortsButton)); | 
					
						
							| 
									
										
										
										
											2023-06-21 19:10:16 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   Future<void> scrollOptionFilterListByOffset(Offset offset) async { | 
					
						
							|  |  |  |     await drag(find.byType(SelectOptionFilterEditor), offset); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   Future<void> enterTextInTextFilter(String text) async { | 
					
						
							|  |  |  |     final findEditor = find.byType(TextFilterEditor); | 
					
						
							|  |  |  |     final findTextField = find.descendant( | 
					
						
							|  |  |  |       of: findEditor, | 
					
						
							|  |  |  |       matching: find.byType(FlowyTextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText(findTextField, text); | 
					
						
							|  |  |  |     await pumpAndSettle(const Duration(milliseconds: 300)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   Future<void> tapDisclosureButtonInFinder(Finder finder) async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     final findDisclosure = find.descendant( | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |       of: finder, | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |       matching: find.byType(DisclosureButton), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(findDisclosure); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   /// must call [tapDisclosureButtonInFinder] first.
 | 
					
						
							|  |  |  |   Future<void> tapDeleteFilterButtonInGrid() async { | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |     await tapButton(find.text(LocaleKeys.grid_settings_deleteFilter.tr())); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapCheckboxFilterButtonInGrid() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(CheckboxFilterConditionList)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   Future<void> tapChecklistFilterButtonInGrid() async { | 
					
						
							|  |  |  |     await tapButton(find.byType(ChecklistFilterConditionList)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// The [SelectOptionFilterList] must show up first.
 | 
					
						
							|  |  |  |   Future<void> tapOptionFilterWithName(String name) async { | 
					
						
							|  |  |  |     final findCell = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(SelectOptionFilterList), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is SelectOptionFilterCell && widget.option.name == name, | 
					
						
							|  |  |  |         skipOffstage: false, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       skipOffstage: false, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     expect(findCell, findsOneWidget); | 
					
						
							| 
									
										
										
										
											2024-01-25 16:37:36 +01:00
										 |  |  |     await tapButton(findCell); | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |   Future<void> tapUnCheckedButtonOnCheckboxFilter() async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(HoverButton), | 
					
						
							|  |  |  |       matching: find.text(LocaleKeys.grid_checkboxFilter_isUnchecked.tr()), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |   Future<void> tapCompletedButtonOnChecklistFilter() async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(HoverButton), | 
					
						
							|  |  |  |       matching: find.text(LocaleKeys.grid_checklistFilter_isComplete.tr()), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |   /// Should call [tapDatabaseSettingButton] first.
 | 
					
						
							|  |  |  |   Future<void> tapViewPropertiesButton() async { | 
					
						
							| 
									
										
										
										
											2023-11-27 06:36:10 +02:00
										 |  |  |     final findSettingItem = find.byType(DatabaseSettingsList); | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |     final findLayoutButton = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FlowyText && | 
					
						
							|  |  |  |           widget.text == DatabaseSettingAction.showProperties.title(), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: findSettingItem, | 
					
						
							|  |  |  |       matching: findLayoutButton, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   /// Should call [tapDatabaseSettingButton] first.
 | 
					
						
							|  |  |  |   Future<void> tapDatabaseLayoutButton() async { | 
					
						
							| 
									
										
										
										
											2023-11-27 06:36:10 +02:00
										 |  |  |     final findSettingItem = find.byType(DatabaseSettingsList); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     final findLayoutButton = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FlowyText && | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |           widget.text == DatabaseSettingAction.showLayout.title(), | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: findSettingItem, | 
					
						
							|  |  |  |       matching: findLayoutButton, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |   Future<void> tapCalendarLayoutSettingButton() async { | 
					
						
							| 
									
										
										
										
											2023-11-27 06:36:10 +02:00
										 |  |  |     final findSettingItem = find.byType(DatabaseSettingsList); | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     final findLayoutButton = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FlowyText && | 
					
						
							|  |  |  |           widget.text == DatabaseSettingAction.showCalendarLayout.title(), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: findSettingItem, | 
					
						
							|  |  |  |       matching: findLayoutButton, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> tapFirstDayOfWeek() async => | 
					
						
							|  |  |  |       tapButton(find.byType(FirstDayOfWeek)); | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapFirstDayOfWeekStartFromMonday() async { | 
					
						
							|  |  |  |     final finder = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is StartFromButton && widget.dayIndex == 1, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(finder); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     // Dismiss the popover overlay in cause of obscure the tapButton
 | 
					
						
							|  |  |  |     // in the next test case.
 | 
					
						
							|  |  |  |     await sendKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							|  |  |  |     await pumpAndSettle(const Duration(milliseconds: 200)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertFirstDayOfWeekStartFromMonday() { | 
					
						
							|  |  |  |     final finder = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is StartFromButton && w.dayIndex == 1 && w.isSelected == true, | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     expect(finder, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertFirstDayOfWeekStartFromSunday() { | 
					
						
							|  |  |  |     final finder = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is StartFromButton && w.dayIndex == 0 && w.isSelected == true, | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     expect(finder, findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   Future<void> scrollToToday() async { | 
					
						
							|  |  |  |     final todayCell = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is CalendarDayCard && widget.isToday, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-07-01 20:29:49 +08:00
										 |  |  |     final scrollable = find | 
					
						
							|  |  |  |         .descendant( | 
					
						
							|  |  |  |           of: find.byType(MonthView<CalendarDayEvent>), | 
					
						
							|  |  |  |           matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |             (widget) => widget is Scrollable && widget.axis == Axis.vertical, | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .first; | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     await scrollUntilVisible(todayCell, 300, scrollable: scrollable); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     await pumpAndSettle(const Duration(milliseconds: 300)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 16:31:54 +02:00
										 |  |  |   Future<void> hoverOnTodayCalendarCell({ | 
					
						
							|  |  |  |     Future<void> Function()? onHover, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     final todayCell = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is CalendarDayCard && widget.isToday, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 16:31:54 +02:00
										 |  |  |     await hoverOnWidget(todayCell, onHover: onHover); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapAddCalendarEventButton() async { | 
					
						
							|  |  |  |     final findFlowyButton = find.byType(FlowyIconButton); | 
					
						
							|  |  |  |     final findNewEventButton = find.byType(NewEventButton); | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: findNewEventButton, | 
					
						
							|  |  |  |       matching: findFlowyButton, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   /// Checks for a certain number of events. Parameters [date] and [title] can
 | 
					
						
							|  |  |  |   /// also be provided to restrict the scope of the search
 | 
					
						
							|  |  |  |   void assertNumberOfEventsInCalendar(int number, {String? title}) { | 
					
						
							|  |  |  |     Finder findEvents = find.byType(EventCard); | 
					
						
							|  |  |  |     if (title != null) { | 
					
						
							|  |  |  |       findEvents = find.descendant(of: findEvents, matching: find.text(title)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     expect(findEvents, findsNWidgets(number)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |   void assertNumberOfEventsOnSpecificDay( | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     int number, | 
					
						
							|  |  |  |     DateTime date, { | 
					
						
							|  |  |  |     String? title, | 
					
						
							|  |  |  |   }) { | 
					
						
							|  |  |  |     final findDayCell = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (widget) => widget is CalendarDayCard && isSameDay(widget.date, date), | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     Finder findEvents = find.descendant( | 
					
						
							|  |  |  |       of: findDayCell, | 
					
						
							|  |  |  |       matching: find.byType(EventCard), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     if (title != null) { | 
					
						
							|  |  |  |       findEvents = find.descendant(of: findEvents, matching: find.text(title)); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     expect(findEvents, findsNWidgets(number)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> doubleClickCalendarCell(DateTime date) async { | 
					
						
							|  |  |  |     final todayCell = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is CalendarDayCard && isSameDay(date, widget.date), | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     final location = getTopLeft(todayCell).translate(10, 10); | 
					
						
							|  |  |  |     await doubleTapAt(location); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-10-23 11:44:04 +08:00
										 |  |  |   Future<void> openCalendarEvent({required int index, DateTime? date}) async { | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     final findDayCell = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is CalendarDayCard && | 
					
						
							|  |  |  |           isSameDay(widget.date, date ?? DateTime.now()), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     final cards = find.descendant( | 
					
						
							|  |  |  |       of: findDayCell, | 
					
						
							|  |  |  |       matching: find.byType(EventCard), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(cards.at(index)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   void assertEventEditorOpen() => | 
					
						
							|  |  |  |       expect(find.byType(CalendarEventEditor), findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   Future<void> dismissEventEditor() async => | 
					
						
							|  |  |  |       simulateKeyEvent(LogicalKeyboardKey.escape); | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Future<void> editEventTitle(String title) async { | 
					
						
							|  |  |  |     final textField = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(CalendarEventEditor), | 
					
						
							|  |  |  |       matching: find.byType(FlowyTextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText(textField, title); | 
					
						
							|  |  |  |     await pumpAndSettle(const Duration(milliseconds: 300)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> openEventToRowDetailPage() async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(CalendarEventEditor), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => widget is FlowySvg && widget.svg == FlowySvgs.full_view_s, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> deleteEventFromEventEditor() async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(CalendarEventEditor), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => widget is FlowySvg && widget.svg == FlowySvgs.delete_s, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 16:31:54 +02:00
										 |  |  |   Future<void> dragDropRescheduleCalendarEvent() async { | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |     final findEventCard = find.byType(EventCard); | 
					
						
							|  |  |  |     await drag(findEventCard.first, const Offset(0, 300)); | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |     await pumpAndSettle(const Duration(microseconds: 300)); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-23 09:47:48 +08:00
										 |  |  |   Future<void> openUnscheduledEventsPopup() async { | 
					
						
							|  |  |  |     final button = find.byType(UnscheduledEventsButton); | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void findUnscheduledPopup(Matcher matcher, int numUnscheduledEvents) { | 
					
						
							|  |  |  |     expect(find.byType(UnscheduleEventsList), matcher); | 
					
						
							|  |  |  |     if (matcher != findsNothing) { | 
					
						
							|  |  |  |       expect( | 
					
						
							|  |  |  |         find.byType(UnscheduledEventCell), | 
					
						
							|  |  |  |         findsNWidgets(numUnscheduledEvents), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> clickUnscheduledEvent() async { | 
					
						
							|  |  |  |     final unscheduledEvent = find.byType(UnscheduledEventCell); | 
					
						
							|  |  |  |     await tapButton(unscheduledEvent); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-21 22:54:09 +08:00
										 |  |  |   Future<void> tapCreateLinkedDatabaseViewButton( | 
					
						
							|  |  |  |     DatabaseLayoutPB layoutType, | 
					
						
							|  |  |  |   ) async { | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     final findAddButton = find.byType(AddDatabaseViewButton); | 
					
						
							|  |  |  |     await tapButton(findAddButton); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final findCreateButton = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							| 
									
										
										
										
											2023-11-21 22:54:09 +08:00
										 |  |  |           widget is TabBarAddButtonActionCell && widget.action == layoutType, | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(findCreateButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 |  |  |   void assertNumberOfGroups(int number) { | 
					
						
							|  |  |  |     final groups = find.byType(BoardColumnHeader, skipOffstage: false); | 
					
						
							|  |  |  |     expect(groups, findsNWidgets(number)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> scrollBoardToEnd() async { | 
					
						
							|  |  |  |     final scrollable = find | 
					
						
							|  |  |  |         .descendant( | 
					
						
							|  |  |  |           of: find.byType(AppFlowyBoard), | 
					
						
							|  |  |  |           matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |             (widget) => widget is Scrollable && widget.axis == Axis.horizontal, | 
					
						
							|  |  |  |           ), | 
					
						
							|  |  |  |         ) | 
					
						
							|  |  |  |         .first; | 
					
						
							|  |  |  |     await scrollUntilVisible( | 
					
						
							|  |  |  |       find.byType(BoardTrailing), | 
					
						
							|  |  |  |       300, | 
					
						
							|  |  |  |       scrollable: scrollable, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapNewGroupButton() async { | 
					
						
							|  |  |  |     final button = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(BoardTrailing), | 
					
						
							|  |  |  |       matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => widget is FlowySvg && widget.svg == FlowySvgs.add_s, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     expect(button, findsOneWidget); | 
					
						
							|  |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   void assertNewGroupTextField(bool isVisible) { | 
					
						
							|  |  |  |     final textField = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(BoardTrailing), | 
					
						
							|  |  |  |       matching: find.byType(TextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     if (isVisible) { | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       return expect(textField, findsOneWidget); | 
					
						
							| 
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     expect(textField, findsNothing); | 
					
						
							| 
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> enterNewGroupName(String name, {required bool submit}) async { | 
					
						
							|  |  |  |     final textField = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(BoardTrailing), | 
					
						
							|  |  |  |       matching: find.byType(TextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await enterText(textField, name); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  |     if (submit) { | 
					
						
							|  |  |  |       await testTextInput.receiveAction(TextInputAction.done); | 
					
						
							|  |  |  |       await pumpAndSettle(); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> clearNewGroupTextField() async { | 
					
						
							|  |  |  |     final textField = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(BoardTrailing), | 
					
						
							|  |  |  |       matching: find.byType(TextField), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: textField, | 
					
						
							|  |  |  |         matching: find.byWidgetPredicate( | 
					
						
							|  |  |  |           (widget) => | 
					
						
							|  |  |  |               widget is FlowySvg && widget.svg == FlowySvgs.close_filled_m, | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     final textFieldWidget = widget<TextField>(textField); | 
					
						
							|  |  |  |     assert( | 
					
						
							|  |  |  |       textFieldWidget.controller != null && | 
					
						
							|  |  |  |           textFieldWidget.controller!.text.isEmpty, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |   Future<void> tapTabBarLinkedViewByViewName(String name) async { | 
					
						
							|  |  |  |     final viewButton = findTabBarLinkViewByViewName(name); | 
					
						
							|  |  |  |     await tapButton(viewButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |   Finder findTabBarLinkViewByViewLayout(ViewLayoutPB layout) { | 
					
						
							|  |  |  |     return find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is TabBarItemButton && widget.view.layout == layout, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Finder findTabBarLinkViewByViewName(String name) { | 
					
						
							|  |  |  |     return find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => widget is TabBarItemButton && widget.view.name == name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> renameLinkedView(Finder linkedView, String name) async { | 
					
						
							|  |  |  |     await tap(linkedView, buttons: kSecondaryButton); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is ActionCellWidget && | 
					
						
							|  |  |  |             widget.action == TabBarViewAction.rename, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await enterText( | 
					
						
							|  |  |  |       find.descendant( | 
					
						
							|  |  |  |         of: find.byType(FlowyFormTextInput), | 
					
						
							|  |  |  |         matching: find.byType(TextFormField), | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |       name, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is PrimaryTextButton && | 
					
						
							| 
									
										
										
										
											2023-10-25 06:29:50 -07:00
										 |  |  |           widget.label == LocaleKeys.button_ok.tr(), | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(field); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> deleteDatebaseView(Finder linkedView) async { | 
					
						
							|  |  |  |     await tap(linkedView, buttons: kSecondaryButton); | 
					
						
							|  |  |  |     await pumpAndSettle(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is ActionCellWidget && | 
					
						
							|  |  |  |             widget.action == TabBarViewAction.delete, | 
					
						
							|  |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     final okButton = find.byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is PrimaryTextButton && | 
					
						
							| 
									
										
										
										
											2023-10-25 06:29:50 -07:00
										 |  |  |           widget.label == LocaleKeys.button_ok.tr(), | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(okButton); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   void assertCurrentDatabaseTagIs(DatabaseLayoutPB layout) => switch (layout) { | 
					
						
							|  |  |  |         DatabaseLayoutPB.Board => | 
					
						
							| 
									
										
										
										
											2024-05-10 10:02:10 +08:00
										 |  |  |           expect(find.byType(DesktopBoardPage), findsOneWidget), | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |         DatabaseLayoutPB.Calendar => | 
					
						
							|  |  |  |           expect(find.byType(CalendarPage), findsOneWidget), | 
					
						
							|  |  |  |         DatabaseLayoutPB.Grid => expect(find.byType(GridPage), findsOneWidget), | 
					
						
							|  |  |  |         _ => throw Exception('Unknown database layout type: $layout'), | 
					
						
							|  |  |  |       }; | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |   Future<void> selectDatabaseLayoutType(DatabaseLayoutPB layout) async { | 
					
						
							|  |  |  |     final findLayoutCell = find.byType(DatabaseViewLayoutCell); | 
					
						
							|  |  |  |     final findText = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-11-21 22:54:09 +08:00
										 |  |  |       (widget) => widget is FlowyText && widget.text == layout.layoutName, | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     final button = find.descendant(of: findLayoutCell, matching: findText); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     await tapButton(button); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> assertCurrentDatabaseLayoutType(DatabaseLayoutPB layout) async { | 
					
						
							|  |  |  |     expect(finderForDatabaseLayoutType(layout), findsOneWidget); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapDatabaseRawDataButton() async { | 
					
						
							|  |  |  |     await tapButtonWithName(LocaleKeys.importPanel_database.tr()); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-07-15 08:45:44 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |   // Use in edit mode of FieldEditor
 | 
					
						
							|  |  |  |   Future<void> changeNumberFieldFormat() async { | 
					
						
							|  |  |  |     final changeFormatButton = find.descendant( | 
					
						
							|  |  |  |       of: find.byType(FieldTypeOptionEditor), | 
					
						
							|  |  |  |       matching: find.text("Number"), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     await tapButton(changeFormatButton); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |         (w) => w is NumberFormatCell && w.format == NumberFormatPB.USD, | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       ), | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Use in edit mode of FieldEditor
 | 
					
						
							| 
									
										
										
										
											2023-07-15 08:45:44 +07:00
										 |  |  |   Future<void> tapAddSelectOptionButton() async { | 
					
						
							|  |  |  |     await tapButtonWithName(LocaleKeys.grid_field_addSelectOption.tr()); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapViewTogglePropertyVisibilityButtonByName( | 
					
						
							|  |  |  |     String fieldName, | 
					
						
							|  |  |  |   ) async { | 
					
						
							|  |  |  |     final field = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       (w) => w is DatabasePropertyCell && w.fieldInfo.name == fieldName, | 
					
						
							| 
									
										
										
										
											2023-09-02 00:42:46 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |     final toggleVisibilityButton = | 
					
						
							|  |  |  |         find.descendant(of: field, matching: find.byType(FlowyIconButton)); | 
					
						
							|  |  |  |     await tapButton(toggleVisibilityButton); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  | Finder finderForDatabaseLayoutType(DatabaseLayoutPB layout) => switch (layout) { | 
					
						
							| 
									
										
										
										
											2024-05-10 10:02:10 +08:00
										 |  |  |       DatabaseLayoutPB.Board => find.byType(DesktopBoardPage), | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |       DatabaseLayoutPB.Calendar => find.byType(CalendarPage), | 
					
						
							|  |  |  |       DatabaseLayoutPB.Grid => find.byType(GridPage), | 
					
						
							|  |  |  |       _ => throw Exception('Unknown database layout type: $layout'), | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Finder finderForFieldType(FieldType fieldType) { | 
					
						
							|  |  |  |   switch (fieldType) { | 
					
						
							|  |  |  |     case FieldType.Checkbox: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableCheckboxCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.DateTime: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableDateCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.LastEditedTime: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is EditableTimestampCell && | 
					
						
							|  |  |  |             widget.fieldType == FieldType.LastEditedTime, | 
					
						
							|  |  |  |         skipOffstage: false, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.CreatedTime: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is EditableTimestampCell && | 
					
						
							|  |  |  |             widget.fieldType == FieldType.CreatedTime, | 
					
						
							|  |  |  |         skipOffstage: false, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.SingleSelect: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is EditableSelectOptionCell && | 
					
						
							|  |  |  |             widget.fieldType == FieldType.SingleSelect, | 
					
						
							|  |  |  |         skipOffstage: false, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.MultiSelect: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byWidgetPredicate( | 
					
						
							|  |  |  |         (widget) => | 
					
						
							|  |  |  |             widget is EditableSelectOptionCell && | 
					
						
							|  |  |  |             widget.fieldType == FieldType.MultiSelect, | 
					
						
							|  |  |  |         skipOffstage: false, | 
					
						
							|  |  |  |       ); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.Checklist: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableChecklistCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.Number: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableNumberCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.RichText: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableTextCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     case FieldType.URL: | 
					
						
							| 
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 |  |  |       return find.byType(EditableURLCell, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-14 22:16:33 +08:00
										 |  |  |     default: | 
					
						
							|  |  |  |       throw Exception('Unknown field type: $fieldType'); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |