| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  | import 'dart:async'; | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | import 'dart:io'; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | import 'package:appflowy/env/cloud_env.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/env/cloud_env_test.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | import 'package:appflowy/startup/entry_point.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/startup/startup.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  | import 'package:appflowy/user/application/auth/af_cloud_mock_auth_service.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/user/application/auth/auth_service.dart'; | 
					
						
							|  |  |  | import 'package:appflowy/user/application/auth/supabase_mock_auth_service.dart'; | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  | import 'package:appflowy/user/presentation/presentation.dart'; | 
					
						
							| 
									
										
										
										
											2023-11-02 15:24:17 +08:00
										 |  |  | import 'package:appflowy/user/presentation/screens/sign_in_screen/widgets/widgets.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  | import 'package:appflowy/workspace/application/settings/prelude.dart'; | 
					
						
							|  |  |  | import 'package:flowy_infra/uuid.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  | import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | 
					
						
							| 
									
										
										
										
											2024-08-07 11:37:30 +08:00
										 |  |  | import 'package:flutter/gestures.dart'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | import 'package:flutter_test/flutter_test.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  | import 'package:path/path.dart' as p; | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  | import 'package:path_provider/path_provider.dart'; | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  | class FlowyTestContext { | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |   FlowyTestContext({required this.applicationDataDirectory}); | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |   final String applicationDataDirectory; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  | extension AppFlowyTestBase on WidgetTester { | 
					
						
							|  |  |  |   Future<FlowyTestContext> initializeAppFlowy({ | 
					
						
							|  |  |  |     // use to append after the application data directory
 | 
					
						
							|  |  |  |     String? pathExtension, | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |     // use to specify the application data directory, if not specified, a temporary directory will be used.
 | 
					
						
							|  |  |  |     String? dataDirectory, | 
					
						
							| 
									
										
										
										
											2024-01-29 10:26:45 +08:00
										 |  |  |     Size windowSize = const Size(1600, 1200), | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |     AuthenticatorType? cloudType, | 
					
						
							| 
									
										
										
										
											2023-12-21 08:12:40 +08:00
										 |  |  |     String? email, | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2024-03-05 17:20:27 +08:00
										 |  |  |     if (Platform.isLinux || Platform.isWindows || Platform.isMacOS) { | 
					
						
							|  |  |  |       // Set the window size
 | 
					
						
							|  |  |  |       await binding.setSurfaceSize(windowSize); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     mockHotKeyManagerHandlers(); | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |     final applicationDataDirectory = dataDirectory ?? | 
					
						
							|  |  |  |         await mockApplicationDataStorage( | 
					
						
							|  |  |  |           pathExtension: pathExtension, | 
					
						
							|  |  |  |         ); | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     await FlowyRunner.run( | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |       AppFlowyApplication(), | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |       IntegrationMode.integrationTest, | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |       rustEnvsBuilder: () { | 
					
						
							|  |  |  |         final rustEnvs = <String, String>{}; | 
					
						
							|  |  |  |         if (cloudType != null) { | 
					
						
							|  |  |  |           switch (cloudType) { | 
					
						
							|  |  |  |             case AuthenticatorType.local: | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |             case AuthenticatorType.supabase: | 
					
						
							|  |  |  |               break; | 
					
						
							| 
									
										
										
										
											2024-01-12 14:34:59 +08:00
										 |  |  |             case AuthenticatorType.appflowyCloudSelfHost: | 
					
						
							|  |  |  |               rustEnvs["GOTRUE_ADMIN_EMAIL"] = "admin@example.com"; | 
					
						
							|  |  |  |               rustEnvs["GOTRUE_ADMIN_PASSWORD"] = "password"; | 
					
						
							|  |  |  |               break; | 
					
						
							| 
									
										
										
										
											2024-01-15 12:53:53 +08:00
										 |  |  |             default: | 
					
						
							|  |  |  |               throw Exception("not supported"); | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return rustEnvs; | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |       didInitGetItCallback: () { | 
					
						
							|  |  |  |         return Future( | 
					
						
							|  |  |  |           () async { | 
					
						
							|  |  |  |             if (cloudType != null) { | 
					
						
							|  |  |  |               switch (cloudType) { | 
					
						
							|  |  |  |                 case AuthenticatorType.local: | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |                   await useLocalServer(); | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |                   break; | 
					
						
							|  |  |  |                 case AuthenticatorType.supabase: | 
					
						
							| 
									
										
										
										
											2024-01-30 09:33:34 +08:00
										 |  |  |                   await useTestSupabaseCloud(); | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |                   getIt.unregister<AuthService>(); | 
					
						
							|  |  |  |                   getIt.registerFactory<AuthService>( | 
					
						
							|  |  |  |                     () => SupabaseMockAuthService(), | 
					
						
							|  |  |  |                   ); | 
					
						
							|  |  |  |                   break; | 
					
						
							| 
									
										
										
										
											2024-01-12 14:34:59 +08:00
										 |  |  |                 case AuthenticatorType.appflowyCloudSelfHost: | 
					
						
							| 
									
										
										
										
											2024-01-30 09:33:34 +08:00
										 |  |  |                   await useTestSelfHostedAppFlowyCloud(); | 
					
						
							| 
									
										
										
										
											2024-01-12 14:34:59 +08:00
										 |  |  |                   getIt.unregister<AuthService>(); | 
					
						
							|  |  |  |                   getIt.registerFactory<AuthService>( | 
					
						
							|  |  |  |                     () => AppFlowyCloudMockAuthService(email: email), | 
					
						
							|  |  |  |                   ); | 
					
						
							| 
									
										
										
										
											2024-01-15 12:53:53 +08:00
										 |  |  |                 default: | 
					
						
							|  |  |  |                   throw Exception("not supported"); | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |               } | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |             } | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |           }, | 
					
						
							|  |  |  |         ); | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |     await waitUntilSignInPageShow(); | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     return FlowyTestContext( | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |       applicationDataDirectory: applicationDataDirectory, | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |   void mockHotKeyManagerHandlers() { | 
					
						
							| 
									
										
										
										
											2023-05-28 05:09:39 +01:00
										 |  |  |     TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  |         .setMockMethodCallHandler(const MethodChannel('hotkey_manager'), | 
					
						
							|  |  |  |             (MethodCall methodCall) async { | 
					
						
							|  |  |  |       if (methodCall.method == 'unregisterAll') { | 
					
						
							|  |  |  |         // do nothing
 | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       return; | 
					
						
							|  |  |  |     }); | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-15 22:43:07 +08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |   Future<void> waitUntilSignInPageShow() async { | 
					
						
							| 
									
										
										
										
											2023-11-24 11:54:47 +08:00
										 |  |  |     if (isAuthEnabled) { | 
					
						
							| 
									
										
										
										
											2024-04-11 16:33:28 +08:00
										 |  |  |       final finder = find.byType(SignInAnonymousButtonV2); | 
					
						
							| 
									
										
										
										
											2024-03-05 17:20:27 +08:00
										 |  |  |       await pumpUntilFound(finder, timeout: const Duration(seconds: 30)); | 
					
						
							| 
									
										
										
										
											2023-11-02 15:24:17 +08:00
										 |  |  |       expect(finder, findsOneWidget); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       final finder = find.byType(GoButton); | 
					
						
							|  |  |  |       await pumpUntilFound(finder); | 
					
						
							|  |  |  |       expect(finder, findsOneWidget); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |   Future<void> waitForSeconds(int seconds) async { | 
					
						
							| 
									
										
										
										
											2024-01-25 16:37:36 +01:00
										 |  |  |     await Future.delayed(Duration(seconds: seconds), () {}); | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |   Future<void> pumpUntilFound( | 
					
						
							|  |  |  |     Finder finder, { | 
					
						
							|  |  |  |     Duration timeout = const Duration(seconds: 10), | 
					
						
							| 
									
										
										
										
											2024-03-05 13:51:03 +08:00
										 |  |  |     Duration pumpInterval = const Duration( | 
					
						
							|  |  |  |       milliseconds: 50, | 
					
						
							|  |  |  |     ), // Interval between pumps
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |   }) async { | 
					
						
							|  |  |  |     bool timerDone = false; | 
					
						
							|  |  |  |     final timer = Timer(timeout, () => timerDone = true); | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |     while (!timerDone) { | 
					
						
							|  |  |  |       await pump(pumpInterval); // Pump with an interval
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |       if (any(finder)) { | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |         break; | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     timer.cancel(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-03-05 13:51:03 +08:00
										 |  |  |   Future<void> pumpUntilNotFound( | 
					
						
							|  |  |  |     Finder finder, { | 
					
						
							|  |  |  |     Duration timeout = const Duration(seconds: 10), | 
					
						
							|  |  |  |     Duration pumpInterval = const Duration( | 
					
						
							|  |  |  |       milliseconds: 50, | 
					
						
							|  |  |  |     ), // Interval between pumps
 | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     bool timerDone = false; | 
					
						
							|  |  |  |     final timer = Timer(timeout, () => timerDone = true); | 
					
						
							|  |  |  |     while (!timerDone) { | 
					
						
							|  |  |  |       await pump(pumpInterval); // Pump with an interval
 | 
					
						
							|  |  |  |       if (!any(finder)) { | 
					
						
							|  |  |  |         break; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     timer.cancel(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   Future<void> tapButton( | 
					
						
							|  |  |  |     Finder finder, { | 
					
						
							|  |  |  |     int? pointer, | 
					
						
							|  |  |  |     int buttons = kPrimaryButton, | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     bool warnIfMissed = false, | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |     int milliseconds = 500, | 
					
						
							| 
									
										
										
										
											2024-05-10 16:08:32 +02:00
										 |  |  |     bool pumpAndSettle = true, | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |     await tap( | 
					
						
							|  |  |  |       finder, | 
					
						
							| 
									
										
										
										
											2023-06-20 23:48:34 +08:00
										 |  |  |       buttons: buttons, | 
					
						
							| 
									
										
										
										
											2023-06-16 14:32:32 +08:00
										 |  |  |       warnIfMissed: warnIfMissed, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2024-05-10 16:08:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     if (pumpAndSettle) { | 
					
						
							|  |  |  |       await this.pumpAndSettle( | 
					
						
							|  |  |  |         Duration(milliseconds: milliseconds), | 
					
						
							|  |  |  |         EnginePhase.sendSemanticsUpdate, | 
					
						
							|  |  |  |         const Duration(seconds: 5), | 
					
						
							|  |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-05-10 16:08:32 +02:00
										 |  |  |   Future<void> tapButtonWithName( | 
					
						
							|  |  |  |     String tr, { | 
					
						
							|  |  |  |     int milliseconds = 500, | 
					
						
							|  |  |  |     bool pumpAndSettle = true, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2024-04-30 14:09:08 +02:00
										 |  |  |     Finder button = find.text(tr, findRichText: true, skipOffstage: false); | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |     if (button.evaluate().isEmpty) { | 
					
						
							|  |  |  |       button = find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |         (widget) => widget is FlowyText && widget.text == tr, | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-05-10 16:08:32 +02:00
										 |  |  |     await tapButton( | 
					
						
							|  |  |  |       button, | 
					
						
							|  |  |  |       milliseconds: milliseconds, | 
					
						
							|  |  |  |       pumpAndSettle: pumpAndSettle, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |   Future<void> doubleTapAt( | 
					
						
							|  |  |  |     Offset location, { | 
					
						
							|  |  |  |     int? pointer, | 
					
						
							|  |  |  |     int buttons = kPrimaryButton, | 
					
						
							|  |  |  |     int milliseconds = 500, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     await tapAt(location, pointer: pointer, buttons: buttons); | 
					
						
							|  |  |  |     await pump(kDoubleTapMinTime); | 
					
						
							|  |  |  |     await tapAt(location, pointer: pointer, buttons: buttons); | 
					
						
							|  |  |  |     await pumpAndSettle(Duration(milliseconds: milliseconds)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   Future<void> wait(int milliseconds) async { | 
					
						
							|  |  |  |     await pumpAndSettle(Duration(milliseconds: milliseconds)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-06-15 16:33:44 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | extension AppFlowyFinderTestBase on CommonFinders { | 
					
						
							|  |  |  |   Finder findTextInFlowyText(String text) { | 
					
						
							|  |  |  |     return find.byWidgetPredicate( | 
					
						
							| 
									
										
										
										
											2023-06-16 15:32:28 +08:00
										 |  |  |       (widget) => widget is FlowyText && widget.text == text, | 
					
						
							| 
									
										
										
										
											2023-06-15 16:33:44 +08:00
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2024-08-07 11:37:30 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Finder findFlowyTooltip(String richMessage, {bool skipOffstage = true}) { | 
					
						
							|  |  |  |     return byWidgetPredicate( | 
					
						
							|  |  |  |       (widget) => | 
					
						
							|  |  |  |           widget is FlowyTooltip && | 
					
						
							|  |  |  |           widget.richMessage != null && | 
					
						
							|  |  |  |           widget.richMessage!.toPlainText().contains(richMessage), | 
					
						
							|  |  |  |       skipOffstage: skipOffstage, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2023-06-15 16:33:44 +08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:33:34 +08:00
										 |  |  | Future<void> useTestSupabaseCloud() async { | 
					
						
							|  |  |  |   await useSupabaseCloud( | 
					
						
							|  |  |  |     url: TestEnv.supabaseUrl, | 
					
						
							|  |  |  |     anonKey: TestEnv.supabaseAnonKey, | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2024-01-30 09:33:34 +08:00
										 |  |  | Future<void> useTestSelfHostedAppFlowyCloud() async { | 
					
						
							|  |  |  |   await useSelfHostedAppFlowyCloudWithURL(TestEnv.afCloudUrl); | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  | 
 | 
					
						
							|  |  |  | Future<String> mockApplicationDataStorage({ | 
					
						
							|  |  |  |   // use to append after the application data directory
 | 
					
						
							|  |  |  |   String? pathExtension, | 
					
						
							|  |  |  | }) async { | 
					
						
							|  |  |  |   final dir = await getTemporaryDirectory(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   // Use a random uuid to avoid conflict.
 | 
					
						
							|  |  |  |   String path = p.join(dir.path, 'appflowy_integration_test', uuid()); | 
					
						
							|  |  |  |   if (pathExtension != null && pathExtension.isNotEmpty) { | 
					
						
							|  |  |  |     path = '$path/$pathExtension'; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  |   final directory = Directory(path); | 
					
						
							|  |  |  |   if (!directory.existsSync()) { | 
					
						
							|  |  |  |     await directory.create(recursive: true); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   MockApplicationDataStorage.initialPath = directory.path; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   return directory.path; | 
					
						
							|  |  |  | } |