| 
					
				 | 
			
			
				@@ -1,48 +1,36 @@ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import 'package:appflowy/startup/startup.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import 'package:appflowy/startup/tasks/prelude.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import 'package:appflowy/workspace/application/settings/prelude.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import 'package:appflowy/workspace/application/settings/settings_location_cubit.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import 'package:flowy_infra/uuid.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import 'package:flutter_test/flutter_test.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import 'package:integration_test/integration_test.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import 'package:path/path.dart' as p; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import 'util/mock/mock_file_picker.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import 'util/util.dart'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import 'package:path/path.dart' as p; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 void main() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   IntegrationTestWidgetsFlutterBinding.ensureInitialized(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   group('customize the folder path', () { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    const location = 'appflowy'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    setUp(() async { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(location); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.setTestLocation(location); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tearDown(() async { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(location); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    tearDownAll(() async { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(null); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     testWidgets('switch to B from A, then switch to A again', (tester) async { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      final userA = uuid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      final userB = uuid(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      const userA = 'UserA'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      const userB = 'UserB'; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(userA); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(userB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.setTestLocation(p.join(userA, appFlowyDataFolder)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await tester.initializeAppFlowy(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      final initialPath = p.join(userA, appFlowyDataFolder); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      final context = await tester.initializeAppFlowy( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        pathExtension: initialPath, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      // remove the last extension 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      final rootPath = context.applicationDataDirectory.replaceFirst( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        initialPath, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        '', 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+      ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       await tester.tapGoButton(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       tester.expectToSeeHomePage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       // switch to user B 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // set user name to userA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // set user name for userA 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.openSettings(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.openSettingsPage(SettingsPage.user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.enterUserName(userA); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -51,12 +39,14 @@ void main() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // mock the file_picker result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        await mockGetDirectoryPath(userB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await mockGetDirectoryPath( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          p.join(rootPath, userB), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.tapCustomLocationButton(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         tester.expectToSeeHomePage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        // set user name to userB 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // set user name for userB 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.openSettings(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.openSettingsPage(SettingsPage.user); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.enterUserName(userB); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -68,7 +58,9 @@ void main() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // mock the file_picker result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        await mockGetDirectoryPath(userA); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await mockGetDirectoryPath( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          p.join(rootPath, userA), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.tapCustomLocationButton(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -83,16 +75,15 @@ void main() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // mock the file_picker result 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        await mockGetDirectoryPath(userB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await mockGetDirectoryPath( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+          p.join(rootPath, userB), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.tapCustomLocationButton(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         await tester.pumpAndSettle(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         tester.expectToSeeHomePage(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         tester.expectToSeeUserName(userB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(userA); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-      await TestFolder.cleanTestLocation(userB); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     testWidgets('reset to default location', (tester) async { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -109,8 +100,8 @@ void main() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       await tester.restoreLocation(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       expect( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        await TestFolder.defaultDevelopmentLocation(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        await TestFolder.currentLocation(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await appFlowyApplicationDataDirectory().then((value) => value.path), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        await getIt<ApplicationDataStorage>().getPath(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				       ); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				   }); 
			 |