Files
Prisma/test/features/tab_navigation_preservation_test.dart
T
RarDog 28a63483da
Build and Release / Build Windows x64 (push) Has been cancelled
Build and Release / Build macOS (push) Has been cancelled
feat: persist last active tab and preserve per-tab navigation state
2026-09-05 15:59:02 +03:00

48 lines
2.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:gel_rule_app/backend/backend.dart';
import 'package:gel_rule_app/shared/widgets/app_shell.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
group('Tab Navigation & State Preservation Tests', () {
test('AppShell branchIndexForLocation and locationForBranchIndex map correctly', () {
expect(AppShell.branchIndexForLocation('/'), 0);
expect(AppShell.branchIndexForLocation('/?q=test'), 0);
expect(AppShell.branchIndexForLocation('/search'), 1);
expect(AppShell.branchIndexForLocation('/favorites'), 2);
expect(AppShell.branchIndexForLocation('/viewed'), 3);
expect(AppShell.branchIndexForLocation('/collections'), 4);
expect(AppShell.branchIndexForLocation('/collections/123'), 4);
expect(AppShell.branchIndexForLocation('/artists'), 5);
expect(AppShell.branchIndexForLocation('/artists/pawchive/patreon/99'), 5);
expect(AppShell.branchIndexForLocation('/providers'), 6);
expect(AppShell.branchIndexForLocation('/settings'), 7);
expect(AppShell.branchIndexForLocation('/settings/hidden'), 7);
expect(AppShell.locationForBranchIndex(0), '/');
expect(AppShell.locationForBranchIndex(1), '/search');
expect(AppShell.locationForBranchIndex(2), '/favorites');
expect(AppShell.locationForBranchIndex(3), '/viewed');
expect(AppShell.locationForBranchIndex(4), '/collections');
expect(AppShell.locationForBranchIndex(5), '/artists');
expect(AppShell.locationForBranchIndex(6), '/providers');
expect(AppShell.locationForBranchIndex(7), '/settings');
});
test('AppSettings preserves lastActiveLocation in JSON serialization', () {
const defaults = AppSettings.defaults;
expect(defaults.lastActiveLocation, '/');
final updated = defaults.copyWith(lastActiveLocation: '/artists/pawchive/patreon/12345');
expect(updated.lastActiveLocation, '/artists/pawchive/patreon/12345');
final json = updated.toJson();
expect(json['lastActiveLocation'], '/artists/pawchive/patreon/12345');
final restored = AppSettings.fromJson(json);
expect(restored.lastActiveLocation, '/artists/pawchive/patreon/12345');
});
});
}