TF-2840 calendar event reject integrate interactor to SingleEmailController
This commit is contained in:
@@ -11,6 +11,7 @@ import 'package:tmail_ui_user/features/email/data/repository/calendar_event_repo
|
||||
import 'package:tmail_ui_user/features/email/domain/repository/calendar_event_repository.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_accept_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/maybe_calendar_event_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_reject_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/parse_calendar_event_interactor.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/cache_exception_thrower.dart';
|
||||
import 'package:tmail_ui_user/main/exceptions/remote_exception_thrower.dart';
|
||||
@@ -38,6 +39,7 @@ class CalendarEventInteractorBindings extends InteractorsBindings {
|
||||
Get.lazyPut(() => ParseCalendarEventInteractor(Get.find<CalendarEventRepository>()));
|
||||
Get.lazyPut(() => AcceptCalendarEventInteractor(Get.find<CalendarEventRepository>()));
|
||||
Get.lazyPut(() => MaybeCalendarEventInteractor(Get.find<CalendarEventRepository>()));
|
||||
Get.lazyPut(() => RejectCalendarEventInteractor(Get.find<CalendarEventRepository>()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -38,6 +38,7 @@ import 'package:tmail_ui_user/features/email/domain/model/move_to_mailbox_reques
|
||||
import 'package:tmail_ui_user/features/email/domain/model/send_receipt_to_sender_request.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_accept_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_maybe_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_reject_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/calendar_event_reply_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/download_attachment_for_web_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/state/download_attachments_state.dart';
|
||||
@@ -53,6 +54,7 @@ import 'package:tmail_ui_user/features/email/domain/state/unsubscribe_email_stat
|
||||
import 'package:tmail_ui_user/features/email/domain/state/view_attachment_for_web_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_accept_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/maybe_calendar_event_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_reject_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachment_for_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachments_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/export_attachment_interactor.dart';
|
||||
@@ -127,6 +129,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
ParseCalendarEventInteractor? _parseCalendarEventInteractor;
|
||||
AcceptCalendarEventInteractor? _acceptCalendarEventInteractor;
|
||||
MaybeCalendarEventInteractor? _maybeCalendarEventInteractor;
|
||||
RejectCalendarEventInteractor? _rejectCalendarEventInteractor;
|
||||
|
||||
final emailContents = RxnString();
|
||||
final attachments = <Attachment>[].obs;
|
||||
@@ -393,6 +396,7 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
_parseCalendarEventInteractor = getBinding<ParseCalendarEventInteractor>();
|
||||
_acceptCalendarEventInteractor = getBinding<AcceptCalendarEventInteractor>();
|
||||
_maybeCalendarEventInteractor = getBinding<MaybeCalendarEventInteractor>();
|
||||
_rejectCalendarEventInteractor = getBinding<RejectCalendarEventInteractor>();
|
||||
}
|
||||
|
||||
void _injectCalendarEventBindings(Session? session, AccountId? accountId) {
|
||||
@@ -1698,6 +1702,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
case EventActionType.maybe:
|
||||
_maybeCalendarEventAction();
|
||||
break;
|
||||
case EventActionType.no:
|
||||
_rejectCalendarEventAction();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -1705,9 +1712,9 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
|
||||
void _acceptCalendarEventAction() {
|
||||
if (_acceptCalendarEventInteractor == null
|
||||
|| _displayingEventBlobId == null
|
||||
|| mailboxDashBoardController.accountId.value == null) {
|
||||
consumeState(Stream.value(Left(CalendarEventAcceptFailure())));
|
||||
|| _displayingEventBlobId == null
|
||||
|| mailboxDashBoardController.accountId.value == null) {
|
||||
consumeState(Stream.value(Left(CalendarEventAcceptFailure())));
|
||||
} else {
|
||||
consumeState(_acceptCalendarEventInteractor!.execute(
|
||||
mailboxDashBoardController.accountId.value!,
|
||||
@@ -1715,11 +1722,23 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
}
|
||||
}
|
||||
|
||||
void _rejectCalendarEventAction() {
|
||||
if (_rejectCalendarEventInteractor == null
|
||||
|| _displayingEventBlobId == null
|
||||
|| mailboxDashBoardController.accountId.value == null) {
|
||||
consumeState(Stream.value(Left(CalendarEventRejectFailure())));
|
||||
} else {
|
||||
consumeState(_rejectCalendarEventInteractor!.execute(
|
||||
mailboxDashBoardController.accountId.value!,
|
||||
{_displayingEventBlobId!}));
|
||||
}
|
||||
}
|
||||
|
||||
void _maybeCalendarEventAction() {
|
||||
if (_maybeCalendarEventInteractor == null
|
||||
|| _displayingEventBlobId == null
|
||||
|| mailboxDashBoardController.accountId.value == null) {
|
||||
consumeState(Stream.value(Left(CalendarEventMaybeFailure())));
|
||||
|| _displayingEventBlobId == null
|
||||
|| mailboxDashBoardController.accountId.value == null) {
|
||||
consumeState(Stream.value(Left(CalendarEventMaybeFailure())));
|
||||
} else {
|
||||
consumeState(_maybeCalendarEventInteractor!.execute(
|
||||
mailboxDashBoardController.accountId.value!,
|
||||
@@ -1734,6 +1753,14 @@ class SingleEmailController extends BaseController with AppLoaderMixin {
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
appLocalization.youWillAttendThisMeeting);
|
||||
} else if (success is CalendarEventMaybeSuccess) {
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
appLocalization.youMayAttendThisMeeting);
|
||||
} else if (success is CalendarEventRejected) {
|
||||
appToast.showToastSuccessMessage(
|
||||
currentOverlayContext!,
|
||||
appLocalization.youWillNotAttendThisMeeting);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_s
|
||||
import 'package:tmail_ui_user/features/email/domain/state/view_attachment_for_web_state.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_accept_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/maybe_calendar_event_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/calendar_event_reject_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachment_for_web_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachments_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/email/domain/usecases/export_attachment_interactor.dart';
|
||||
@@ -79,6 +80,7 @@ const fallbackGenerators = {
|
||||
MockSpec<PrintEmailInteractor>(),
|
||||
MockSpec<AcceptCalendarEventInteractor>(),
|
||||
MockSpec<MaybeCalendarEventInteractor>(),
|
||||
MockSpec<RejectCalendarEventInteractor>(),
|
||||
])
|
||||
void main() {
|
||||
TestWidgetsFlutterBinding.ensureInitialized();
|
||||
@@ -322,5 +324,32 @@ void main() {
|
||||
verify(maybeCalendarEventInteractor.execute(testAccountId, {blobId})).called(1);
|
||||
});
|
||||
});
|
||||
|
||||
group('reject test:', () {
|
||||
final rejectCalendarEventInteractor = MockRejectCalendarEventInteractor();
|
||||
|
||||
test('should call execute on RejectCalendarEventInteractor '
|
||||
'when onCalendarEventReplyAction is called on EventActionType.yes', () async {
|
||||
// arrange
|
||||
when(mailboxDashboardController.selectedEmail).thenReturn(Rxn(null));
|
||||
when(mailboxDashboardController.emailUIAction).thenReturn(Rxn(null));
|
||||
when(mailboxDashboardController.viewState).thenReturn(Rx(Right(UIState.idle)));
|
||||
singleEmailController.onInit();
|
||||
Get.put<RejectCalendarEventInteractor>(rejectCalendarEventInteractor);
|
||||
mailboxDashboardController.accountId.refresh();
|
||||
singleEmailController.handleSuccessViewState(
|
||||
ParseCalendarEventSuccess([
|
||||
BlobCalendarEvent(
|
||||
blobId: blobId,
|
||||
calendarEventList: [calendarEvent])]));
|
||||
|
||||
// act
|
||||
singleEmailController.onCalendarEventReplyAction(EventActionType.no);
|
||||
await untilCalled(rejectCalendarEventInteractor.execute(any, any));
|
||||
|
||||
// assert
|
||||
verify(rejectCalendarEventInteractor.execute(testAccountId, {blobId})).called(1);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user