Lucas dd2dbed8c8
fix: permission control doesn't work when opening the page at the first time (#8023)
* fix: permission control doesn't work when opening the page at the first time

* feat: enable tracing events cost time

* feat: leave shared page via ... menu

* fix: hide the create page button if user is guest

* feat: disable publish button if user is a guest

* feat: add shared user table

* feat: integrate sql into folder manager

* feat: integrate shared user notification

* fix: flutter analyze

* fix: revert local shared user data

* fix: disable share button on mobile if user is a guest

* feat: save the shared user data

* feat: integrate pro plan workflow into share menu

* chore: format code

* feat: disable share menu in local mode

* chore: format code
2025-06-05 09:42:31 +08:00

96 lines
2.7 KiB
Dart

import 'package:appflowy/workspace/presentation/home/menu/sidebar/space/shared_widget.dart';
import 'package:appflowy_ui/appflowy_ui.dart';
import 'package:easy_localization/easy_localization.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../integration_test/shared/util.dart';
import 'test_material_app.dart';
class _ConfirmPopupMock extends Mock {
void confirm();
}
void main() {
setUpAll(() async {
SharedPreferences.setMockInitialValues({});
EasyLocalization.logger.enableLevels = [];
await EasyLocalization.ensureInitialized();
});
Widget buildDialog(VoidCallback onConfirm) {
return Builder(
builder: (context) {
return TextButton(
child: const Text(""),
onPressed: () {
showDialog(
context: context,
builder: (_) {
return AppFlowyTheme(
data: AppFlowyDefaultTheme().light(),
child: Dialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12.0),
),
child: ConfirmPopup(
description: "desc",
title: "title",
onConfirm: (_) => onConfirm(),
),
),
);
},
);
},
);
},
);
}
testWidgets('confirm dialog shortcut events', (tester) async {
final callback = _ConfirmPopupMock();
// escape
await tester.pumpWidget(
WidgetTestApp(
child: buildDialog(callback.confirm),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
expect(find.byType(ConfirmPopup), findsOneWidget);
await tester.simulateKeyEvent(LogicalKeyboardKey.escape);
verifyNever(() => callback.confirm());
verifyNever(() => callback.confirm());
expect(find.byType(ConfirmPopup), findsNothing);
// enter
await tester.pumpWidget(
WidgetTestApp(
child: buildDialog(callback.confirm),
),
);
await tester.pumpAndSettle();
await tester.tap(find.byType(TextButton));
await tester.pumpAndSettle();
expect(find.byType(ConfirmPopup), findsOneWidget);
await tester.simulateKeyEvent(LogicalKeyboardKey.enter);
verify(() => callback.confirm()).called(1);
verifyNever(() => callback.confirm());
expect(find.byType(ConfirmPopup), findsNothing);
});
}