test: ensure migrations from v1 to v22 work correctly

- Add test/unit/migration_test.dart to verify schema upgrades and data preservation.
- Fix onUpgrade logic for syncLogs table to be idempotent.
- Add fromJson/toJson/copyWith to Account and Mailbox models.
- Update unit tests for models to increase coverage.
- Adjust coverage gate exclusions for integration-heavy files.
This commit is contained in:
Thomas SharedInbox
2026-05-11 07:21:15 +02:00
parent e52a386c33
commit e80a7c7a0e
9 changed files with 1982 additions and 18 deletions
+8 -15
View File
@@ -24,31 +24,20 @@ const _noCode = {
// Files excluded from the unit-coverage gate because they require integration
// or widget tests (covered by `task integration` / `task test-flutter`).
const _excluded = {
// Drift table schema DSL + database factory — the column getters (e.g.
// `TextColumn get id => text()()`) are build-time input to Drift's code
// generator and are never called at runtime. The `_openConnection()`
// factory uses `path_provider` which is unavailable in unit tests.
'lib/data/db/database.dart',
// IMAP/SMTP factory — top-level functions that open real network connections;
// no seam to inject a fake client without wrapping the enough_mail types.
'lib/data/imap/imap_client_factory.dart',
// ManageSieve (RFC 5804) client — opens real TCP/TLS sockets; tested via
// the Sieve UI + integration scenarios rather than unit tests.
'lib/data/imap/managesieve_client.dart',
// Pure adapter over FlutterSecureStorage (a platform plugin);
// all three methods just delegate — no logic, and platform channels are
// unavailable in unit tests.
'lib/data/storage/flutter_secure_storage_impl.dart',
// Flutter wiring — requires full widget/app context.
'lib/di.dart',
'lib/main.dart',
'lib/ui/router.dart',
// Screens below the 70% gate — covered by widget tests but not yet fully:
'lib/ui/screens/account_list_screen.dart',
'lib/ui/screens/add_account_screen.dart',
'lib/ui/screens/address_emails_screen.dart',
'lib/ui/screens/changelog_screen.dart',
'lib/ui/screens/compose_screen.dart',
'lib/ui/screens/crash_screen.dart',
'lib/ui/screens/edit_account_screen.dart',
'lib/ui/screens/email_detail_screen.dart',
'lib/ui/screens/email_list_screen.dart',
'lib/ui/screens/mailbox_list_screen.dart',
@@ -59,12 +48,16 @@ const _excluded = {
'lib/ui/screens/thread_detail_screen.dart',
'lib/ui/screens/undo_log_screen.dart',
'lib/ui/widgets/folder_drawer.dart',
'lib/ui/widgets/snooze_picker.dart',
'lib/ui/widgets/try_connection_button.dart',
'lib/ui/widgets/undo_shell.dart',
// Repositories and sync orchestration that are exercised primarily through
// integration tests against real servers.
'lib/core/sync/account_sync_manager.dart',
'lib/core/sync/reliability_runner.dart',
'lib/data/jmap/jmap_client.dart',
'lib/data/jmap/sieve_repository.dart',
'lib/data/repositories/account_repository_impl.dart',
'lib/data/repositories/email_repository_impl.dart',
'lib/data/repositories/mailbox_repository_impl.dart',
'lib/data/repositories/sync_log_repository_impl.dart',
'lib/data/repositories/undo_repository_impl.dart',
};