| 
									
										
										
										
											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'; | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | import 'package:dartz/dartz.dart'; | 
					
						
							| 
									
										
										
										
											2023-07-02 23:37:30 +08:00
										 |  |  | import 'package:flowy_infra/uuid.dart'; | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  | import 'package:flowy_infra_ui/flowy_infra_ui.dart'; | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  | import 'package:flutter/gestures.dart'; | 
					
						
							|  |  |  | import 'package:flutter/services.dart'; | 
					
						
							|  |  |  | 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 { | 
					
						
							|  |  |  |   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, | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     Size windowsSize = 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 { | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |     // view.physicalSize = windowsSize;
 | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     binding.setSurfaceSize(windowsSize); | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +08:00
										 |  |  |     // addTearDown(() => binding.setSurfaceSize(null));
 | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							|  |  |  |             case AuthenticatorType.appflowyCloud: | 
					
						
							|  |  |  |               rustEnvs["GOTRUE_ADMIN_EMAIL"] = "admin@example.com"; | 
					
						
							|  |  |  |               rustEnvs["GOTRUE_ADMIN_PASSWORD"] = "password"; | 
					
						
							|  |  |  |               break; | 
					
						
							|  |  |  |           } | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |         return rustEnvs; | 
					
						
							|  |  |  |       }, | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |       didInitGetItCallback: () { | 
					
						
							|  |  |  |         return Future( | 
					
						
							|  |  |  |           () async { | 
					
						
							|  |  |  |             if (cloudType != null) { | 
					
						
							|  |  |  |               switch (cloudType) { | 
					
						
							|  |  |  |                 case AuthenticatorType.local: | 
					
						
							| 
									
										
										
										
											2023-12-21 08:12:40 +08:00
										 |  |  |                   await useLocal(); | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |                   break; | 
					
						
							|  |  |  |                 case AuthenticatorType.supabase: | 
					
						
							|  |  |  |                   await useSupabaseCloud(); | 
					
						
							|  |  |  |                   getIt.unregister<AuthService>(); | 
					
						
							|  |  |  |                   getIt.registerFactory<AuthService>( | 
					
						
							|  |  |  |                     () => SupabaseMockAuthService(), | 
					
						
							|  |  |  |                   ); | 
					
						
							|  |  |  |                   break; | 
					
						
							|  |  |  |                 case AuthenticatorType.appflowyCloud: | 
					
						
							|  |  |  |                   await useAppFlowyCloud(); | 
					
						
							|  |  |  |                   getIt.unregister<AuthService>(); | 
					
						
							|  |  |  |                   getIt.registerFactory<AuthService>( | 
					
						
							| 
									
										
										
										
											2023-12-21 08:12:40 +08:00
										 |  |  |                     () => AppFlowyCloudMockAuthService(email: email), | 
					
						
							| 
									
										
										
										
											2023-11-28 15:49:47 -08:00
										 |  |  |                   ); | 
					
						
							|  |  |  |                   break; | 
					
						
							|  |  |  |               } | 
					
						
							| 
									
										
										
										
											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) { | 
					
						
							| 
									
										
										
										
											2023-11-02 15:24:17 +08:00
										 |  |  |       final finder = find.byType(SignInAnonymousButton); | 
					
						
							|  |  |  |       await pumpUntilFound(finder); | 
					
						
							|  |  |  |       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 { | 
					
						
							|  |  |  |     await Future.delayed((Duration(seconds: seconds)), () {}); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-09-14 19:22:32 +08:00
										 |  |  |   Future<void> pumpUntilFound( | 
					
						
							|  |  |  |     Finder finder, { | 
					
						
							|  |  |  |     Duration timeout = const Duration(seconds: 10), | 
					
						
							| 
									
										
										
										
											2023-12-26 02:03:42 +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(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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, | 
					
						
							|  |  |  |   }) 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, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |     await pumpAndSettle(Duration(milliseconds: milliseconds)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapButtonWithName( | 
					
						
							|  |  |  |     String tr, { | 
					
						
							|  |  |  |     int milliseconds = 500, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-06-12 14:36:55 +08:00
										 |  |  |     Finder button = find.text( | 
					
						
							|  |  |  |       tr, | 
					
						
							|  |  |  |       findRichText: true, | 
					
						
							|  |  |  |       skipOffstage: false, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     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
										 |  |  |       ); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |     await tapButton( | 
					
						
							|  |  |  |       button, | 
					
						
							|  |  |  |       milliseconds: milliseconds, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   Future<void> tapButtonWithTooltip( | 
					
						
							|  |  |  |     String tr, { | 
					
						
							|  |  |  |     int milliseconds = 500, | 
					
						
							|  |  |  |   }) async { | 
					
						
							|  |  |  |     final button = find.byTooltip(tr); | 
					
						
							|  |  |  |     await tapButton( | 
					
						
							|  |  |  |       button, | 
					
						
							|  |  |  |       milliseconds: milliseconds, | 
					
						
							|  |  |  |     ); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   Future<void> doubleTapButton( | 
					
						
							|  |  |  |     Finder finder, { | 
					
						
							|  |  |  |     int? pointer, | 
					
						
							|  |  |  |     int buttons = kPrimaryButton, | 
					
						
							|  |  |  |     bool warnIfMissed = true, | 
					
						
							|  |  |  |     int milliseconds = 500, | 
					
						
							|  |  |  |   }) async { | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     await tap( | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |       finder, | 
					
						
							|  |  |  |       pointer: pointer, | 
					
						
							|  |  |  |       buttons: buttons, | 
					
						
							|  |  |  |       warnIfMissed: warnIfMissed, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     await pump(kDoubleTapMinTime); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     await tap( | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |       finder, | 
					
						
							|  |  |  |       buttons: buttons, | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |       pointer: pointer, | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |       warnIfMissed: warnIfMissed, | 
					
						
							|  |  |  |     ); | 
					
						
							| 
									
										
										
										
											2023-07-09 10:03:22 +07:00
										 |  |  |     await pumpAndSettle(Duration(milliseconds: milliseconds)); | 
					
						
							| 
									
										
										
										
											2023-06-22 23:40:49 +08:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2022-12-20 11:14:42 +08:00
										 |  |  |   Future<void> wait(int milliseconds) async { | 
					
						
							|  |  |  |     await pumpAndSettle(Duration(milliseconds: milliseconds)); | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											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
										 |  |  |     ); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-12-21 08:12:40 +08:00
										 |  |  | Future<void> useLocal() async { | 
					
						
							|  |  |  |   await setAuthenticatorType(AuthenticatorType.local); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  | Future<void> useSupabaseCloud() async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   await setAuthenticatorType(AuthenticatorType.supabase); | 
					
						
							| 
									
										
										
										
											2023-11-25 01:18:31 -08:00
										 |  |  |   await setSupbaseServer( | 
					
						
							|  |  |  |     Some(TestEnv.supabaseUrl), | 
					
						
							|  |  |  |     Some(TestEnv.supabaseAnonKey), | 
					
						
							|  |  |  |   ); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | Future<void> useAppFlowyCloud() async { | 
					
						
							| 
									
										
										
										
											2023-11-27 18:54:31 -08:00
										 |  |  |   await setAuthenticatorType(AuthenticatorType.appflowyCloud); | 
					
						
							| 
									
										
										
										
											2023-12-21 08:12:40 +08:00
										 |  |  |   await setAppFlowyCloudUrl(Some(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; | 
					
						
							|  |  |  | } |