From 619d90ac16ac4942ca2ef5b9073202fd0f38fe53 Mon Sep 17 00:00:00 2001 From: DatDang Date: Wed, 23 Oct 2024 16:24:27 +0700 Subject: [PATCH 1/2] TF-3222 Hide reply calendar event action buttons if email is event reply --- .../email/presentation/extensions/calendar_event_extension.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/features/email/presentation/extensions/calendar_event_extension.dart b/lib/features/email/presentation/extensions/calendar_event_extension.dart index 26713e87fe..3c6ef8f32a 100644 --- a/lib/features/email/presentation/extensions/calendar_event_extension.dart +++ b/lib/features/email/presentation/extensions/calendar_event_extension.dart @@ -356,6 +356,7 @@ extension CalendarEventExtension on CalendarEvent { } bool get isDisplayedEventReplyAction => method != null + && method != EventMethod.reply && organizer != null && participants?.isNotEmpty == true; } \ No newline at end of file From eadbd4faf3a63852afb26dc2e591e417607d4db0 Mon Sep 17 00:00:00 2001 From: DatDang Date: Thu, 24 Oct 2024 09:45:09 +0700 Subject: [PATCH 2/2] fixup! TF-3222 Hide reply calendar event action buttons if email is event reply --- .../extensions/calendar_event_extension.dart | 7 +- .../calendar_event_extension_test.dart | 121 ++++++++++++++++++ 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/lib/features/email/presentation/extensions/calendar_event_extension.dart b/lib/features/email/presentation/extensions/calendar_event_extension.dart index 3c6ef8f32a..2a7c895e0d 100644 --- a/lib/features/email/presentation/extensions/calendar_event_extension.dart +++ b/lib/features/email/presentation/extensions/calendar_event_extension.dart @@ -356,7 +356,12 @@ extension CalendarEventExtension on CalendarEvent { } bool get isDisplayedEventReplyAction => method != null - && method != EventMethod.reply + && _methodIsRepliable && organizer != null && participants?.isNotEmpty == true; + + bool get _methodIsRepliable => + method == EventMethod.request || + method == EventMethod.add || + method == EventMethod.counter; } \ No newline at end of file diff --git a/test/features/email/presentation/extensions/calendar_event_extension_test.dart b/test/features/email/presentation/extensions/calendar_event_extension_test.dart index 11c86f2ad9..96e968e7e5 100644 --- a/test/features/email/presentation/extensions/calendar_event_extension_test.dart +++ b/test/features/email/presentation/extensions/calendar_event_extension_test.dart @@ -3,6 +3,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:date_format/date_format.dart' as date_format; import 'package:jmap_dart_client/jmap/core/utc_date.dart'; import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/properties/attendee/calendar_attendee.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/properties/calendar_organizer.dart'; +import 'package:jmap_dart_client/jmap/mail/calendar/properties/event_method.dart'; import 'package:tmail_ui_user/features/email/presentation/extensions/calendar_event_extension.dart'; void main() { @@ -73,4 +76,122 @@ void main() { expect(formattedDateString, expectedFormattedDateString); }); }); + + group('calendar_event_extension::isDisplayedEventReplyAction::test:', () { + CalendarEvent calendarEventFromEventMethod(EventMethod eventMethod) { + return CalendarEvent( + method: eventMethod, + organizer: CalendarOrganizer(), + participants: [CalendarAttendee()] + ); + } + + group('should return true', () { + test( + 'when event method is request', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.request); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, true); + }); + + test( + 'when event method is add', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.add); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, true); + }); + + test( + 'when event method is counter', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.counter); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, true); + }); + }); + + group('should return false', () { + test( + 'when event method is publish', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.publish); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, false); + }); + + test( + 'when event method is reply', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.reply); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, false); + }); + + test( + 'when event method is cancel', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.cancel); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, false); + }); + + test( + 'when event method is refresh', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.refresh); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, false); + }); + + test( + 'when event method is declineCounter', + () { + // arrange + final calendarEvent = calendarEventFromEventMethod(EventMethod.declineCounter); + + // act + final result = calendarEvent.isDisplayedEventReplyAction; + + // assert + expect(result, false); + }); + }); + }); } \ No newline at end of file