Skip to content

Commit a0d8711

Browse files
authored
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
1 parent c24b684 commit a0d8711

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
11
# Release Notes
2+
# Release Notes
3+
## Version 0.7.4 - 19/11/2024
4+
### New Features
5+
- Support uploading WebP and BMP images
6+
- Support managing workspaces on mobile
7+
- Support adding toggle headings on mobile
8+
- Improve the AI chat page UI
9+
### Bug Fixes
10+
- Optimized the workspace menu loading performance
11+
- Optimized tab switching performance
12+
- Fixed searching issues in Document page
13+
214
## Version 0.7.3 - 07/11/2024
315
### New Features
416
- Enable custom URLs for published pages
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
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+
}

frontend/appflowy_flutter/integration_test/desktop/cloud/workspace/workspace_test_runner.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:integration_test/integration_test.dart';
33
import 'change_name_and_icon_test.dart' as change_name_and_icon_test;
44
import 'collaborative_workspace_test.dart' as collaborative_workspace_test;
55
import 'share_menu_test.dart' as share_menu_test;
6+
import 'tabs_test.dart' as tabs_test;
67
import 'workspace_icon_test.dart' as workspace_icon_test;
78
import 'workspace_settings_test.dart' as workspace_settings_test;
89

@@ -14,4 +15,5 @@ void main() {
1415
collaborative_workspace_test.main();
1516
change_name_and_icon_test.main();
1617
workspace_icon_test.main();
18+
tabs_test.main();
1719
}

frontend/appflowy_flutter/lib/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_menu.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import 'package:appflowy/generated/flowy_svgs.g.dart';
33
import 'package:appflowy/generated/locale_keys.g.dart';
44
import 'package:appflowy/startup/startup.dart';
55
import 'package:appflowy/user/application/auth/auth_service.dart';
6+
import 'package:appflowy/workspace/application/tabs/tabs_bloc.dart';
67
import 'package:appflowy/workspace/application/user/user_workspace_bloc.dart';
78
import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_actions.dart';
89
import 'package:appflowy/workspace/presentation/home/menu/sidebar/workspace/_sidebar_workspace_icon.dart';
@@ -297,12 +298,16 @@ class _WorkspaceInfo extends StatelessWidget {
297298

298299
void _openWorkspace(BuildContext context) {
299300
if (!isSelected) {
301+
// close the other tabs before opening another workspace.
302+
getIt<TabsBloc>().add(const TabsEvent.closeOtherTabs(''));
303+
300304
Log.info('open workspace: ${workspace.workspaceId}');
301305
context.read<UserWorkspaceBloc>().add(
302306
UserWorkspaceEvent.openWorkspace(
303307
workspace.workspaceId,
304308
),
305309
);
310+
306311
PopoverContainer.of(context).closeAll();
307312
}
308313
}

0 commit comments

Comments
 (0)