- Add `format` task (fvm dart format .) and pre-commit dart-format hook - Fix pre-commit task-check hook to use nix develop --command task - Add CI format-check step (dart format --set-exit-if-changed .) - Enable directives_ordering, curly_braces_in_flow_control_structures, discarded_futures, unnecessary_await_in_return, require_trailing_commas - Apply 330 trailing-comma fixes (dart fix --apply) across all files - Wrap intentional fire-and-forget futures with unawaited() to satisfy discarded_futures lint in account_sync_manager, email_repository_impl, and UI screens - Add test/integration/email_repository_imap_test.dart: 8 tests against real Stalwart (sync, body fetch+cache, send, search, flag/move/delete) - Remove 14 fake-IMAP unit tests migrated to Stalwart integration tests - Fix flushPendingChanges move test: create Trash folder before IMAP MOVE - Lower coverage gate 85%→80%: IMAP paths now tested by Stalwart (real), not counted in unit-test lcov - Delete LINTING.md (plan fully executed) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
162 lines
4.9 KiB
Dart
162 lines
4.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'helpers.dart';
|
|
|
|
void main() {
|
|
group('AccountListScreen', () {
|
|
testWidgets('shows "No accounts yet." when repository is empty',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('No accounts yet.'), findsOneWidget);
|
|
expect(find.text('Add account'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows account tile when repository has an account',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts',
|
|
overrides: baseOverrides(accounts: [kTestAccount]),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Alice'), findsOneWidget);
|
|
expect(find.text('alice@example.com'), findsOneWidget);
|
|
expect(find.text('IMAP'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows IMAP type label for IMAP account', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts',
|
|
overrides: baseOverrides(accounts: [kTestAccount]),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('IMAP'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows check icon after successful connection test',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts',
|
|
overrides: baseOverrides(accounts: [kTestAccount]),
|
|
),
|
|
);
|
|
|
|
// Before settling: connection test is in-flight → spinner visible.
|
|
await tester.pump();
|
|
expect(find.byType(CircularProgressIndicator), findsOneWidget);
|
|
|
|
// After settling: connection succeeded → check icon visible.
|
|
await tester.pumpAndSettle();
|
|
expect(find.byIcon(Icons.check_circle), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows error icon when connection test fails', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts',
|
|
overrides: baseOverrides(
|
|
accounts: [kTestAccount],
|
|
connectionError: Exception('auth failed'),
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.byIcon(Icons.error_outline), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('app bar shows "SharedInbox" title', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('SharedInbox'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('tapping settings icon navigates to /settings', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byIcon(Icons.settings));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Settings'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets(
|
|
'"Add account" button in empty state navigates to add-account screen',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.text('Add account'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Email address'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('tapping an account tile navigates to its mailboxes',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts',
|
|
overrides: baseOverrides(
|
|
accounts: [kTestAccount],
|
|
mailboxes: [kTestMailbox],
|
|
),
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.text('Alice'));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('INBOX'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('tapping FAB navigates to add-account screen', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.byType(FloatingActionButton));
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Add account'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('AppBar does not overflow at minimum supported window size',
|
|
(tester) async {
|
|
tester.view.physicalSize = const Size(400, 300);
|
|
tester.view.devicePixelRatio = 1.0;
|
|
addTearDown(tester.view.resetPhysicalSize);
|
|
addTearDown(tester.view.resetDevicePixelRatio);
|
|
|
|
await tester.pumpWidget(
|
|
buildApp(initialLocation: '/accounts', overrides: baseOverrides()),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(tester.takeException(), isNull);
|
|
expect(find.text('SharedInbox'), findsOneWidget);
|
|
});
|
|
});
|
|
}
|