2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/generated/locale_keys.g.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-05 17:30:54 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:appflowy/plugins/database/widgets/card/card.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-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:easy_localization/easy_localization.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import 'package:flutter/services.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:flutter_test/flutter_test.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import 'package:integration_test/integration_test.dart';
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								import '../util/util.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								import '../util/database_test_op.dart';
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								void main() {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  IntegrationTestWidgetsFlutterBinding.ensureInitialized();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  group('board row test', () {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    testWidgets('delete item in ToDo card', (tester) async {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.initializeAppFlowy();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapGoButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-27 11:42:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const name = 'Card 1';
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      final card1 = find.text(name);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.hoverOnWidget(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        card1,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        onHover: () async {
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          final moreOption = find.byType(MoreCardOptionsAccessory);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          await tester.tapButton(moreOption);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapButtonWithName(LocaleKeys.button_delete.tr());
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      expect(find.text(name), findsNothing);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    testWidgets('duplicate item in ToDo card', (tester) async {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.initializeAppFlowy();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapGoButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-27 11:42:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      const name = 'Card 1';
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      final card1 = find.text(name);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.hoverOnWidget(
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        card1,
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        onHover: () async {
							 | 
						
					
						
							
								
									
										
										
										
											2024-01-24 23:59:45 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								          final moreOption = find.byType(MoreCardOptionsAccessory);
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								          await tester.tapButton(moreOption);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								        },
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      );
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapButtonWithName(LocaleKeys.button_duplicate.tr());
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      expect(find.textContaining(name, findRichText: true), findsNWidgets(2));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    testWidgets('add new group', (tester) async {
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.initializeAppFlowy();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapGoButton();
							 | 
						
					
						
							
								
									
										
										
										
											2023-12-27 11:42:39 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								      await tester.createNewPageWithNameUnderParent(layout: ViewLayoutPB.Board);
							 | 
						
					
						
							
								
									
										
										
										
											2023-11-06 16:17:05 +08:00
										 
									 
								 
							 | 
							
								
									
										
									
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // assert number of groups
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNumberOfGroups(4);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // scroll the board horizontally to ensure add new group button appears
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.scrollBoardToEnd();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // assert and click on add new group button
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapNewGroupButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // enter new group name and submit
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.enterNewGroupName('needs design', submit: true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // assert number of groups has increased
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNumberOfGroups(5);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // assert text field has disappeared
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.scrollBoardToEnd();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // click on add new group button
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapNewGroupButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // type some things
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.enterNewGroupName('needs planning', submit: false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // click on clear button and assert empty contents
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.clearNewGroupTextField();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // press escape to cancel
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.sendKeyEvent(LogicalKeyboardKey.escape);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.pumpAndSettle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // click on add new group button
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tapNewGroupButton();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(true);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      // press elsewhere to cancel
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.tap(find.byType(AppFlowyBoard));
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      await tester.pumpAndSettle();
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								      tester.assertNewGroupTextField(false);
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								    });
							 | 
						
					
						
							
								
									
										
										
										
											2023-08-01 08:49:48 +05:30
										 
									 
								 
							 | 
							
								
							 | 
							
								
							 | 
							
							
								  });
							 | 
						
					
						
							| 
								
							 | 
							
								
							 | 
							
								
							 | 
							
							
								}
							 |