| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart'; | 
					
						
							| 
									
										
										
										
											2023-12-31 07:29:40 +08:00
										 |  |  | import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | import 'package:flutter/material.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  | import 'package:flutter/services.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							|  |  |  | import 'package:integration_test/integration_test.dart'; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | import 'util/base.dart'; | 
					
						
							|  |  |  | import 'util/common_operations.dart'; | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  | import 'util/expectation.dart'; | 
					
						
							|  |  |  | import 'util/keyboard.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  | const _documentName = 'First Doc'; | 
					
						
							|  |  |  | const _documentTwoName = 'Second Doc'; | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void main() { | 
					
						
							|  |  |  |   IntegrationTestWidgetsFlutterBinding.ensureInitialized(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   group('Tabs', () { | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |     testWidgets('Open AppFlowy and open/navigate/close tabs', (tester) async { | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  |       await tester.initializeAppFlowy(); | 
					
						
							|  |  |  |       await tester.tapGoButton(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(TabsManager), | 
					
						
							|  |  |  |           matching: find.byType(TabBar), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         findsNothing, | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-25 16:37:36 +01:00
										 |  |  |       await tester.createNewPageWithNameUnderParent(name: _documentName); | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-25 16:37:36 +01:00
										 |  |  |       await tester.createNewPageWithNameUnderParent(name: _documentTwoName); | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /// Open second menu item in a new tab
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |       await tester.openAppInNewTab(gettingStarted, ViewLayoutPB.Document); | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       /// Open third menu item in a new tab
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |       await tester.openAppInNewTab(_documentName, ViewLayoutPB.Document); | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |       expect( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(TabBar), | 
					
						
							|  |  |  |           matching: find.byType(FlowyTab), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |         findsNWidgets(3), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |       /// Navigate to the second tab
 | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  |       await tester.tap( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(FlowyTab), | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |           matching: find.text(gettingStarted), | 
					
						
							|  |  |  |         ), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       /// Close tab by shortcut
 | 
					
						
							|  |  |  |       await FlowyTestKeyboard.simulateKeyDownEvent( | 
					
						
							|  |  |  |         [ | 
					
						
							|  |  |  |           Platform.isMacOS | 
					
						
							|  |  |  |               ? LogicalKeyboardKey.meta | 
					
						
							|  |  |  |               : LogicalKeyboardKey.control, | 
					
						
							|  |  |  |           LogicalKeyboardKey.keyW, | 
					
						
							|  |  |  |         ], | 
					
						
							|  |  |  |         tester: tester, | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       expect( | 
					
						
							|  |  |  |         find.descendant( | 
					
						
							|  |  |  |           of: find.byType(TabBar), | 
					
						
							|  |  |  |           matching: find.byType(FlowyTab), | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  |         ), | 
					
						
							| 
									
										
										
										
											2023-08-08 07:09:17 +02:00
										 |  |  |         findsNWidgets(2), | 
					
						
							| 
									
										
										
										
											2023-07-12 13:13:18 +02:00
										 |  |  |       ); | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } |