From a0d8711d5cc611d90ea275ff6df603788a978ddd Mon Sep 17 00:00:00 2001 From: Lucas Date: Tue, 19 Nov 2024 15:41:55 +0800 Subject: [PATCH] fix: close other tabs before switching workspace (#6830) * fix: close other tabs before swtching workspace * test: close other tabs before switching workspace * chore: update release note * test: close other tabs before switching workspace --- CHANGELOG.md | 12 +++ .../desktop/cloud/workspace/tabs_test.dart | 75 +++++++++++++++++++ .../workspace/workspace_test_runner.dart | 2 + .../workspace/_sidebar_workspace_menu.dart | 5 ++ 4 files changed, 94 insertions(+) create mode 100644 frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/tabs_test.dart diff --git a/CHANGELOG.md b/CHANGELOG.md index dc9e7bc89795a..fbec9204a4ccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,16 @@ # Release Notes +# Release Notes +## Version 0.7.4 - 19/11/2024 +### New Features +- Support uploading WebP and BMP images +- Support managing workspaces on mobile +- Support adding toggle headings on mobile +- Improve the AI chat page UI +### Bug Fixes +- Optimized the workspace menu loading performance +- Optimized tab switching performance +- Fixed searching issues in Document page + ## Version 0.7.3 - 07/11/2024 ### New Features - Enable custom URLs for published pages diff --git a/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/tabs_test.dart b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/tabs_test.dart new file mode 100644 index 0000000000000..6661075878d98 --- /dev/null +++ b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/tabs_test.dart @@ -0,0 +1,75 @@ +import 'package:appflowy/env/cloud_env.dart'; +import 'package:appflowy/plugins/document/presentation/editor_plugins/openai/widgets/loading.dart'; +import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart'; +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_test/flutter_test.dart'; +import 'package:integration_test/integration_test.dart'; + +import '../../../shared/constants.dart'; +import '../../../shared/util.dart'; + +void main() { + IntegrationTestWidgetsFlutterBinding.ensureInitialized(); + + group('Tabs', () { + testWidgets('close other tabs before opening a new workspace', + (tester) async { + await tester.initializeAppFlowy( + cloudType: AuthenticatorType.appflowyCloudSelfHost, + ); + await tester.tapGoogleLoginInButton(); + await tester.expectToSeeHomePageWithGetStartedPage(); + + const name = 'AppFlowy.IO'; + // the workspace will be opened after created + await tester.createCollaborativeWorkspace(name); + + final loading = find.byType(Loading); + await tester.pumpUntilNotFound(loading); + + // create new tabs in the workspace + expect(find.byType(FlowyTab), findsNothing); + + const documentOneName = 'document one'; + const documentTwoName = 'document two'; + await tester.createNewPageInSpace( + spaceName: Constants.generalSpaceName, + layout: ViewLayoutPB.Document, + pageName: documentOneName, + ); + await tester.createNewPageInSpace( + spaceName: Constants.generalSpaceName, + layout: ViewLayoutPB.Document, + pageName: documentTwoName, + ); + + /// Open second menu item in a new tab + await tester.openAppInNewTab(documentOneName, ViewLayoutPB.Document); + + /// Open third menu item in a new tab + await tester.openAppInNewTab(documentTwoName, ViewLayoutPB.Document); + + expect( + find.descendant( + of: find.byType(TabsManager), + matching: find.byType(FlowyTab), + ), + findsNWidgets(2), + ); + + // switch to the another workspace + final Finder items = find.byType(WorkspaceMenuItem); + await tester.openCollaborativeWorkspaceMenu(); + await tester.pumpUntilFound(items); + expect(items, findsNWidgets(2)); + + // open the first workspace + await tester.tap(items.first); + await tester.pumpUntilNotFound(loading); + + expect(find.byType(FlowyTab), findsNothing); + }); + }); +} diff --git a/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart index 8ed85e467d512..4d2862038e18c 100644 --- a/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart +++ b/frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart @@ -3,6 +3,7 @@ import 'package:integration_test/integration_test.dart'; import 'change_name_and_icon_test.dart' as change_name_and_icon_test; import 'collaborative_workspace_test.dart' as collaborative_workspace_test; import 'share_menu_test.dart' as share_menu_test; +import 'tabs_test.dart' as tabs_test; import 'workspace_icon_test.dart' as workspace_icon_test; import 'workspace_settings_test.dart' as workspace_settings_test; @@ -14,4 +15,5 @@ void main() { collaborative_workspace_test.main(); change_name_and_icon_test.main(); workspace_icon_test.main(); + tabs_test.main(); } diff --git a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart index 4119239694d78..fc3c53e26074b 100644 --- a/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart +++ b/frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart @@ -3,6 +3,7 @@ import 'package:appflowy/generated/flowy_svgs.g.dart'; import 'package:appflowy/generated/locale_keys.g.dart'; import 'package:appflowy/startup/startup.dart'; import 'package:appflowy/user/application/auth/auth_service.dart'; +import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart'; import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart'; import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_icon.dart'; @@ -297,12 +298,16 @@ class _WorkspaceInfo extends StatelessWidget { void _openWorkspace(BuildContext context) { if (!isSelected) { + // close the other tabs before opening another workspace. + getIt().add(const TabsEvent.closeOtherTabs('')); + Log.info('open workspace: ${workspace.workspaceId}'); context.read().add( UserWorkspaceEvent.openWorkspace( workspace.workspaceId, ), ); + PopoverContainer.of(context).closeAll(); } }