mirror of
				https://github.com/AppFlowy-IO/AppFlowy.git
				synced 2025-10-31 10:03:18 +00:00 
			
		
		
		
	 5facb61e23
			
		
	
	
		5facb61e23
		
			
		
	
	
	
	
		
			
			* chore: rename flowy-folder2 to flowy-folder * chore: rename flowy-document2 to flowy-document * chore: fix test * chore: move lib-infra crate * chore: remove shared-lib * chore: fix clippy
		
			
				
	
	
		
			88 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
			
		
		
	
	
			88 lines
		
	
	
		
			2.3 KiB
		
	
	
	
		
			Dart
		
	
	
	
	
	
| import 'dart:io';
 | |
| 
 | |
| import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart';
 | |
| import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart';
 | |
| import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart';
 | |
| import 'package:flutter/material.dart';
 | |
| import 'package:flutter/services.dart';
 | |
| import 'package:flutter_test/flutter_test.dart';
 | |
| import 'package:integration_test/integration_test.dart';
 | |
| 
 | |
| import 'util/base.dart';
 | |
| import 'util/common_operations.dart';
 | |
| import 'util/expectation.dart';
 | |
| import 'util/keyboard.dart';
 | |
| 
 | |
| const _documentName = 'First Doc';
 | |
| const _documentTwoName = 'Second Doc';
 | |
| 
 | |
| void main() {
 | |
|   IntegrationTestWidgetsFlutterBinding.ensureInitialized();
 | |
| 
 | |
|   group('Tabs', () {
 | |
|     testWidgets('Open AppFlowy and open/navigate/close tabs', (tester) async {
 | |
|       await tester.initializeAppFlowy();
 | |
|       await tester.tapGoButton();
 | |
| 
 | |
|       expect(
 | |
|         find.descendant(
 | |
|           of: find.byType(TabsManager),
 | |
|           matching: find.byType(TabBar),
 | |
|         ),
 | |
|         findsNothing,
 | |
|       );
 | |
| 
 | |
|       await tester.createNewPageWithNameUnderParent(
 | |
|         name: _documentName,
 | |
|         layout: ViewLayoutPB.Document,
 | |
|       );
 | |
| 
 | |
|       await tester.createNewPageWithNameUnderParent(
 | |
|         name: _documentTwoName,
 | |
|         layout: ViewLayoutPB.Document,
 | |
|       );
 | |
| 
 | |
|       /// Open second menu item in a new tab
 | |
|       await tester.openAppInNewTab(gettingStarted, ViewLayoutPB.Document);
 | |
| 
 | |
|       /// Open third menu item in a new tab
 | |
|       await tester.openAppInNewTab(_documentName, ViewLayoutPB.Document);
 | |
| 
 | |
|       expect(
 | |
|         find.descendant(
 | |
|           of: find.byType(TabBar),
 | |
|           matching: find.byType(FlowyTab),
 | |
|         ),
 | |
|         findsNWidgets(3),
 | |
|       );
 | |
| 
 | |
|       /// Navigate to the second tab
 | |
|       await tester.tap(
 | |
|         find.descendant(
 | |
|           of: find.byType(FlowyTab),
 | |
|           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),
 | |
|         ),
 | |
|         findsNWidgets(2),
 | |
|       );
 | |
|     });
 | |
|   });
 | |
| }
 |