diff --git a/lib/ui/screens/email_detail_screen.dart b/lib/ui/screens/email_detail_screen.dart index 2709d03..59097be 100644 --- a/lib/ui/screens/email_detail_screen.dart +++ b/lib/ui/screens/email_detail_screen.dart @@ -74,10 +74,6 @@ class _EmailDetailScreenState extends ConsumerState { return Scaffold( appBar: AppBar( automaticallyImplyLeading: !isMobile, - title: Text( - header?.subject ?? '(loading…)', - overflow: TextOverflow.ellipsis, - ), actions: [ IconButton( icon: const Icon(Icons.reply), @@ -133,12 +129,20 @@ class _EmailDetailScreenState extends ConsumerState { if (mounted) setState(() => _isFlagged = next); }, ), + IconButton( + icon: const Icon(Icons.report_outlined), + tooltip: 'Mark as spam', + onPressed: header == null + ? null + : () { + unawaited(_markAsSpam(context, header)); + }, + ), PopupMenuButton( itemBuilder: (ctx) => [ const PopupMenuItem(value: 'forward', child: Text('Forward')), const PopupMenuItem(value: 'move', child: Text('Move to folder')), const PopupMenuItem(value: 'snooze', child: Text('Snooze')), - const PopupMenuItem(value: 'spam', child: Text('Mark as spam')), const PopupMenuItem( value: 'mark_unread', child: Text('Mark as unread'), @@ -166,8 +170,6 @@ class _EmailDetailScreenState extends ConsumerState { unawaited(_moveTo(context, header)); } else if (value == 'snooze' && header != null) { unawaited(_snooze(context, header)); - } else if (value == 'spam' && header != null) { - unawaited(_markAsSpam(context, header)); } else if (value == 'mark_unread') { final nextEmailId = await _getNextEmailIdIfNeeded(header); await repo.setFlag(widget.emailId, seen: false); diff --git a/test/widget/email_detail_screen_test.dart b/test/widget/email_detail_screen_test.dart index cdd0ba5..b7237bd 100644 --- a/test/widget/email_detail_screen_test.dart +++ b/test/widget/email_detail_screen_test.dart @@ -81,7 +81,7 @@ void main() { expect(find.byType(CircularProgressIndicator), findsOneWidget); }); - testWidgets('shows subject in app bar after data loads', (tester) async { + testWidgets('shows subject in email header section', (tester) async { final email = testEmail(subject: 'Project update'); const body = EmailBody( emailId: 'acc-1:42', @@ -106,8 +106,8 @@ void main() { ); await tester.pumpAndSettle(); - // Subject appears in both the app bar and the email header section. - expect(find.text('Project update'), findsAtLeastNWidgets(1)); + // Subject appears only in the email header section, not in the app bar. + expect(find.text('Project update'), findsOneWidget); expect(find.text('See attached slides.'), findsOneWidget); }); @@ -266,7 +266,7 @@ void main() { expect(find.textContaining('carol@example.com'), findsAtLeastNWidgets(1)); }); - testWidgets('Mark as spam is in popup menu, not a standalone button', ( + testWidgets('Mark as spam is a standalone button, not in popup menu', ( tester, ) async { await tester.pumpWidget( @@ -279,19 +279,19 @@ void main() { ); await tester.pumpAndSettle(); - // No standalone icon button for mark as spam. + // Standalone icon button for mark as spam is in the app bar. expect( find.byWidgetPredicate( (w) => w is Tooltip && w.message == 'Mark as spam', ), - findsNothing, + findsOneWidget, ); - // It appears in the popup menu. + // It does NOT appear in the popup menu. await tester.tap(find.byType(PopupMenuButton)); await tester.pumpAndSettle(); - expect(find.text('Mark as spam'), findsOneWidget); + expect(find.text('Mark as spam'), findsNothing); }); testWidgets('Mark as spam shows dialog when no junk folder', ( @@ -309,11 +309,11 @@ void main() { ); await tester.pumpAndSettle(); - // Open the popup menu first, then tap Mark as spam. - await tester.tap(find.byType(PopupMenuButton)); - await tester.pumpAndSettle(); - - await tester.tap(find.text('Mark as spam')); + await tester.tap( + find.byWidgetPredicate( + (w) => w is Tooltip && w.message == 'Mark as spam', + ), + ); await tester.pumpAndSettle(); expect(find.text('No spam folder found'), findsOneWidget); diff --git a/test/widget/email_list_screen_test.dart b/test/widget/email_list_screen_test.dart index 67404fb..32cd3fe 100644 --- a/test/widget/email_list_screen_test.dart +++ b/test/widget/email_list_screen_test.dart @@ -446,10 +446,10 @@ void main() { await tester.pumpAndSettle(); expect(find.byType(EmailDetailScreen), findsOneWidget); - // The detail AppBar title shows the first email's subject. + // The detail body header shows the first email's subject. expect( find.descendant( - of: find.byType(AppBar), + of: find.byType(EmailDetailScreen), matching: find.text('Alpha Match'), ), findsOneWidget,