- 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>
98 lines
3.1 KiB
Dart
98 lines
3.1 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
import 'package:sharedinbox/core/models/mailbox.dart';
|
|
import 'package:sharedinbox/di.dart';
|
|
|
|
import 'helpers.dart';
|
|
|
|
void main() {
|
|
group('MailboxListScreen', () {
|
|
testWidgets('shows mailbox name', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts/acc-1/mailboxes',
|
|
overrides: [
|
|
accountRepositoryProvider
|
|
.overrideWithValue(FakeAccountRepository([kTestAccount])),
|
|
mailboxRepositoryProvider
|
|
.overrideWithValue(FakeMailboxRepository([kTestMailbox])),
|
|
emailRepositoryProvider.overrideWithValue(FakeEmailRepository()),
|
|
],
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('INBOX'), findsWidgets);
|
|
});
|
|
|
|
testWidgets('shows unread badge when unreadCount > 0', (tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts/acc-1/mailboxes',
|
|
overrides: [
|
|
accountRepositoryProvider
|
|
.overrideWithValue(FakeAccountRepository([kTestAccount])),
|
|
mailboxRepositoryProvider
|
|
.overrideWithValue(FakeMailboxRepository([kTestMailbox])),
|
|
emailRepositoryProvider.overrideWithValue(FakeEmailRepository()),
|
|
],
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
// kTestMailbox has unreadCount = 3
|
|
expect(find.text('3'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('tapping a mailbox tile navigates to its email list',
|
|
(tester) async {
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts/acc-1/mailboxes',
|
|
overrides: [
|
|
accountRepositoryProvider
|
|
.overrideWithValue(FakeAccountRepository([kTestAccount])),
|
|
mailboxRepositoryProvider
|
|
.overrideWithValue(FakeMailboxRepository([kTestMailbox])),
|
|
emailRepositoryProvider.overrideWithValue(FakeEmailRepository()),
|
|
],
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
await tester.tap(find.text('INBOX').first);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('No emails'), findsOneWidget);
|
|
});
|
|
|
|
testWidgets('shows no badge when unreadCount is zero', (tester) async {
|
|
const emptyMailbox = Mailbox(
|
|
id: 'acc-1:Sent',
|
|
accountId: 'acc-1',
|
|
path: 'Sent',
|
|
name: 'Sent',
|
|
unreadCount: 0,
|
|
totalCount: 5,
|
|
);
|
|
await tester.pumpWidget(
|
|
buildApp(
|
|
initialLocation: '/accounts/acc-1/mailboxes',
|
|
overrides: [
|
|
accountRepositoryProvider
|
|
.overrideWithValue(FakeAccountRepository([kTestAccount])),
|
|
mailboxRepositoryProvider
|
|
.overrideWithValue(FakeMailboxRepository([emptyMailbox])),
|
|
emailRepositoryProvider.overrideWithValue(FakeEmailRepository()),
|
|
],
|
|
),
|
|
);
|
|
await tester.pumpAndSettle();
|
|
|
|
expect(find.text('Sent'), findsOneWidget);
|
|
expect(find.byType(Badge), findsNothing);
|
|
});
|
|
});
|
|
}
|