Files
sharedinbox/test/widget/edit_account_screen_test.dart
T
Thomas GüttlerandClaude Sonnet 4.6 be56232f00 feat: linting + format automation + IMAP integration tests against Stalwart
- 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>
2026-04-20 18:08:09 +02:00

122 lines
3.7 KiB
Dart

import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'helpers.dart';
void main() {
group('EditAccountScreen', () {
testWidgets('shows account email and type label after loading',
(tester) async {
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(accounts: [kTestAccount]),
),
);
await tester.pumpAndSettle();
expect(find.text('alice@example.com'), findsOneWidget);
// "IMAP" appears as both the type badge and the IMAP section header.
expect(find.text('IMAP'), findsWidgets);
});
testWidgets('pre-fills display name field', (tester) async {
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(accounts: [kTestAccount]),
),
);
await tester.pumpAndSettle();
expect(find.widgetWithText(TextFormField, 'Alice'), findsOneWidget);
});
testWidgets('shows Save button', (tester) async {
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(accounts: [kTestAccount]),
),
);
await tester.pumpAndSettle();
expect(find.text('Save'), findsOneWidget);
});
testWidgets('saving without password change pops back', (tester) async {
tester.view.physicalSize = const Size(800, 1400);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(accounts: [kTestAccount]),
),
);
await tester.pumpAndSettle();
await tester.tap(find.text('Save'));
await tester.pumpAndSettle();
// After saving we pop back to the accounts list.
expect(find.text('No accounts yet.'), findsNothing);
});
testWidgets('saving with new password runs connection test',
(tester) async {
tester.view.physicalSize = const Size(800, 1400);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(accounts: [kTestAccount]),
),
);
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('editPasswordField')),
'newsecret',
);
await tester.tap(find.text('Save'));
await tester.pumpAndSettle();
// Successful save navigates back — edit screen title is gone.
expect(find.text('Edit account'), findsNothing);
});
testWidgets('connection error shows error message', (tester) async {
tester.view.physicalSize = const Size(800, 1400);
tester.view.devicePixelRatio = 1.0;
addTearDown(tester.view.resetPhysicalSize);
addTearDown(tester.view.resetDevicePixelRatio);
await tester.pumpWidget(
buildApp(
initialLocation: '/accounts/acc-1/edit',
overrides: baseOverrides(
accounts: [kTestAccount],
connectionError: Exception('auth failed'),
),
),
);
await tester.pumpAndSettle();
await tester.enterText(
find.byKey(const Key('editPasswordField')),
'wrongpassword',
);
await tester.tap(find.text('Save'));
await tester.pumpAndSettle();
expect(find.textContaining('Save failed'), findsOneWidget);
});
});
}