Skip to content

Bring projects, wikis, and teams together with AI. AppFlowy is the AI collaborative workspace where you achieve more without losing control of your data. The leading open source Notion alternative.

chore: rename test

Nathan5c99572e9304
diff --git a/frontend/appflowy_flutter/integration_test/desktop/cloud/set_env.dart b/frontend/appflowy_flutter/integration_test/desktop/cloud/set_env.dart
index b24c0faf27..df69de7446 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/cloud/set_env.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/cloud/set_env.dart
@@ -8,11 +8,13 @@ import '../../shared/util.dart';
void main() {
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
- group('Empty', () {
- testWidgets('set appflowy cloud', (tester) async {
+ group('Preset cloud env', () {
+ testWidgets('use self-hosted cloud', (tester) async {
await tester.initializeAppFlowy(
cloudType: AuthenticatorType.appflowyCloudSelfHost,
);
+
+ await tester.pumpAndSettle();
});
});
}
diff --git a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart
index ec61034d40..c18b42939c 100644
--- a/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart
+++ b/frontend/appflowy_flutter/integration_test/desktop/document/document_copy_and_paste_test.dart
@@ -1,6 +1,5 @@
import 'dart:io';
-import 'package:appflowy/env/cloud_env.dart';
import 'package:appflowy/generated/locale_keys.g.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/block_menu/block_menu_button.dart';
import 'package:appflowy/plugins/document/presentation/editor_plugins/copy_and_paste/clipboard_service.dart';
@@ -531,7 +530,6 @@ extension on WidgetTester {
(String, Uint8List?)? image,
}) async {
await initializeAppFlowy();
- await useAppFlowyCloudDevelop("http://localhost");
await tapAnonymousSignInButton();
// create a new document
diff --git a/frontend/appflowy_flutter/integration_test/shared/base.dart b/frontend/appflowy_flutter/integration_test/shared/base.dart
index bb0489a926..95bda89113 100644
--- a/frontend/appflowy_flutter/integration_test/shared/base.dart
+++ b/frontend/appflowy_flutter/integration_test/shared/base.dart
@@ -41,7 +41,6 @@ extension AppFlowyTestBase on WidgetTester {
AIRepository Function()? aiRepositoryBuilder,
}) async {
if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) {
- // Set the window size
await binding.setSurfaceSize(windowSize);
}
@@ -54,68 +53,12 @@ extension AppFlowyTestBase on WidgetTester {
await FlowyRunner.run(
AppFlowyApplication(),
IntegrationMode.integrationTest,
- rustEnvsBuilder: () {
- final rustEnvs = <String, String>{};
- if (cloudType != null) {
- switch (cloudType) {
- case AuthenticatorType.local:
- break;
- case AuthenticatorType.appflowyCloudSelfHost:
- rustEnvs["GOTRUE_ADMIN_EMAIL"] = "[email protected]";
- rustEnvs["GOTRUE_ADMIN_PASSWORD"] = "password";
- break;
- case AuthenticatorType.appflowyCloudDevelop:
- rustEnvs["GOTRUE_ADMIN_EMAIL"] = "[email protected]";
- rustEnvs["GOTRUE_ADMIN_PASSWORD"] = "password";
- break;
- default:
- throw Exception("not supported");
- }
- }
- return rustEnvs;
- },
- didInitGetItCallback: () {
- return Future(
- () async {
- if (cloudType != null) {
- switch (cloudType) {
- case AuthenticatorType.local:
- await useLocalServer();
- break;
- case AuthenticatorType.appflowyCloudSelfHost:
- await useSelfHostedAppFlowyCloud(TestEnv.afCloudUrl);
- getIt.unregister<AuthService>();
- getIt.unregister<AIRepository>();
-
- getIt.registerFactory<AuthService>(
- () => AppFlowyCloudMockAuthService(email: email),
- );
- getIt.registerFactory<AIRepository>(
- aiRepositoryBuilder ?? () => MockAIRepository(),
- );
- case AuthenticatorType.appflowyCloudDevelop:
- if (integrationMode().isDevelop) {
- await useAppFlowyCloudDevelop("http://localhost");
- } else {
- await useSelfHostedAppFlowyCloud(TestEnv.afCloudUrl);
- }
- getIt.unregister<AuthService>();
- getIt.unregister<AIRepository>();
-
- getIt.registerFactory<AuthService>(
- () => AppFlowyCloudMockAuthService(email: email),
- );
- getIt.registerFactory<AIRepository>(
- aiRepositoryBuilder ?? () => MockAIRepository(),
- );
- break;
- default:
- throw Exception("not supported");
- }
- }
- },
- );
- },
+ rustEnvsBuilder: () => _buildRustEnvs(cloudType),
+ didInitGetItCallback: () => _initializeCloudServices(
+ cloudType: cloudType,
+ email: email,
+ aiRepositoryBuilder: aiRepositoryBuilder,
+ ),
);
await waitUntilSignInPageShow();
@@ -124,6 +67,76 @@ extension AppFlowyTestBase on WidgetTester {
);
}
+ Map<String, String> _buildRustEnvs(AuthenticatorType? cloudType) {
+ final rustEnvs = <String, String>{};
+ if (cloudType != null) {
+ switch (cloudType) {
+ case AuthenticatorType.local:
+ break;
+ case AuthenticatorType.appflowyCloudSelfHost:
+ case AuthenticatorType.appflowyCloudDevelop:
+ rustEnvs["GOTRUE_ADMIN_EMAIL"] = "[email protected]";
+ rustEnvs["GOTRUE_ADMIN_PASSWORD"] = "password";
+ break;
+ default:
+ throw Exception("Unsupported cloud type: $cloudType");
+ }
+ }
+ return rustEnvs;
+ }
+
+ Future<void> _initializeCloudServices({
+ required AuthenticatorType? cloudType,
+ String? email,
+ AIRepository Function()? aiRepositoryBuilder,
+ }) async {
+ if (cloudType == null) return;
+
+ switch (cloudType) {
+ case AuthenticatorType.local:
+ await useLocalServer();
+ break;
+ case AuthenticatorType.appflowyCloudSelfHost:
+ await _setupAppFlowyCloud(
+ useLocal: false,
+ email: email,
+ aiRepositoryBuilder: aiRepositoryBuilder,
+ );
+ break;
+ case AuthenticatorType.appflowyCloudDevelop:
+ await _setupAppFlowyCloud(
+ useLocal: integrationMode().isDevelop,
+ email: email,
+ aiRepositoryBuilder: aiRepositoryBuilder,
+ );
+ break;
+ default:
+ throw Exception("Unsupported cloud type: $cloudType");
+ }
+ }
+
+ Future<void> _setupAppFlowyCloud({
+ required bool useLocal,
+ String? email,
+ AIRepository Function()? aiRepositoryBuilder,
+ }) async {
+ if (useLocal) {
+ await useAppFlowyCloudDevelop("http://localhost");
+ } else {
+ await useSelfHostedAppFlowyCloud(TestEnv.afCloudUrl);
+ }
+
+ getIt.unregister<AuthService>();
+ getIt.unregister<AIRepository>();
+
+ getIt.registerFactory<AuthService>(
+ () => AppFlowyCloudMockAuthService(email: email),
+ );
+ getIt.registerFactory<AIRepository>(
+ aiRepositoryBuilder ?? () => MockAIRepository(),
+ );
+ }
+
void mockHotKeyManagerHandlers() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(const MethodChannel('hotkey_manager'),