mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-18 14:23:42 +00:00
fix(ui): preserve mobile home route and confirm Android exit
This commit is contained in:
1 parent
8f9bac9e6b
commit
ee6b073bc1
7 files changed
+307
-66
No files matched your search
@@ -0,0 +1,36 @@
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:gopeed/app/router/app_router.dart';
|
||||
import 'package:gopeed/features/auth/application/web_auth_controller.dart';
|
||||
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
|
||||
for (final platform in TargetPlatform.values) {
|
||||
test('$platform preserves the expected section route stacks', () {
|
||||
debugDefaultTargetPlatformOverride = platform;
|
||||
addTearDown(() => debugDefaultTargetPlatformOverride = null);
|
||||
final auth = WebAuthController();
|
||||
final router = AppRouter.build(auth);
|
||||
addTearDown(router.dispose);
|
||||
addTearDown(auth.dispose);
|
||||
final isMobile = platform == TargetPlatform.android || platform == TargetPlatform.iOS;
|
||||
|
||||
for (final entry in {
|
||||
'/': ['/'],
|
||||
'/extensions': isMobile ? ['/', 'extensions'] : ['/extensions'],
|
||||
'/extensions/example': isMobile ? ['/', 'extensions', ':id'] : ['/extensions', ':id'],
|
||||
'/settings': isMobile ? ['/', 'settings'] : ['/settings'],
|
||||
'/settings/general': isMobile ? ['/', 'settings', ':section'] : ['/settings', ':section'],
|
||||
'/tasks/example': ['/', 'tasks/:id'],
|
||||
'/create': ['/', 'create'],
|
||||
}.entries) {
|
||||
final match = router.configuration.findMatch(Uri.parse(entry.key));
|
||||
expect(match.isError, isFalse);
|
||||
final shell = match.matches.single as ShellRouteMatch;
|
||||
expect(shell.matches.map((match) => (match.route as GoRoute).path), entry.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user