|
| 1 | +import 'package:appflowy/env/cloud_env.dart'; |
| 2 | +import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart'; |
| 3 | +import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart'; |
| 4 | +import 'package:appflowy/workspace/presentation/home/tabs/flowy_tab.dart'; |
| 5 | +import 'package:appflowy/workspace/presentation/home/tabs/tabs_manager.dart'; |
| 6 | +import 'package:appflowy_backend/protobuf/flowy-folder/view.pb.dart'; |
| 7 | +import 'package:flutter_test/flutter_test.dart'; |
| 8 | +import 'package:integration_test/integration_test.dart'; |
| 9 | + |
| 10 | +import '../../../shared/constants.dart'; |
| 11 | +import '../../../shared/util.dart'; |
| 12 | + |
| 13 | +void main() { |
| 14 | + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); |
| 15 | + |
| 16 | + group('Tabs', () { |
| 17 | + testWidgets('close other tabs before opening a new workspace', |
| 18 | + (tester) async { |
| 19 | + await tester.initializeAppFlowy( |
| 20 | + cloudType: AuthenticatorType.appflowyCloudSelfHost, |
| 21 | + ); |
| 22 | + await tester.tapGoogleLoginInButton(); |
| 23 | + await tester.expectToSeeHomePageWithGetStartedPage(); |
| 24 | + |
| 25 | + const name = 'AppFlowy.IO'; |
| 26 | + // the workspace will be opened after created |
| 27 | + await tester.createCollaborativeWorkspace(name); |
| 28 | + |
| 29 | + final loading = find.byType(Loading); |
| 30 | + await tester.pumpUntilNotFound(loading); |
| 31 | + |
| 32 | + // create new tabs in the workspace |
| 33 | + expect(find.byType(FlowyTab), findsNothing); |
| 34 | + |
| 35 | + const documentOneName = 'document one'; |
| 36 | + const documentTwoName = 'document two'; |
| 37 | + await tester.createNewPageInSpace( |
| 38 | + spaceName: Constants.generalSpaceName, |
| 39 | + layout: ViewLayoutPB.Document, |
| 40 | + pageName: documentOneName, |
| 41 | + ); |
| 42 | + await tester.createNewPageInSpace( |
| 43 | + spaceName: Constants.generalSpaceName, |
| 44 | + layout: ViewLayoutPB.Document, |
| 45 | + pageName: documentTwoName, |
| 46 | + ); |
| 47 | + |
| 48 | + /// Open second menu item in a new tab |
| 49 | + await tester.openAppInNewTab(documentOneName, ViewLayoutPB.Document); |
| 50 | + |
| 51 | + /// Open third menu item in a new tab |
| 52 | + await tester.openAppInNewTab(documentTwoName, ViewLayoutPB.Document); |
| 53 | + |
| 54 | + expect( |
| 55 | + find.descendant( |
| 56 | + of: find.byType(TabsManager), |
| 57 | + matching: find.byType(FlowyTab), |
| 58 | + ), |
| 59 | + findsNWidgets(2), |
| 60 | + ); |
| 61 | + |
| 62 | + // switch to the another workspace |
| 63 | + final Finder items = find.byType(WorkspaceMenuItem); |
| 64 | + await tester.openCollaborativeWorkspaceMenu(); |
| 65 | + await tester.pumpUntilFound(items); |
| 66 | + expect(items, findsNWidgets(2)); |
| 67 | + |
| 68 | + // open the first workspace |
| 69 | + await tester.tap(items.first); |
| 70 | + await tester.pumpUntilNotFound(loading); |
| 71 | + |
| 72 | + expect(find.byType(FlowyTab), findsNothing); |
| 73 | + }); |
| 74 | + }); |
| 75 | +} |
0 commit comments