Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF-3222 Hide reply calendar event action buttons if email is event reply #3224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,12 @@ extension CalendarEventExtension on CalendarEvent {
}

bool get isDisplayedEventReplyAction => method != null
&& _methodIsRepliable
&& organizer != null
&& participants?.isNotEmpty == true;

bool get _methodIsRepliable =>
method == EventMethod.request ||
method == EventMethod.add ||
method == EventMethod.counter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
});
});
});
}
Loading