TF-2764 Remove ViewAttachmentForWebInteractor
This commit is contained in:
@@ -1,29 +0,0 @@
|
|||||||
import 'package:tmail_ui_user/features/email/domain/state/download_attachment_for_web_state.dart';
|
|
||||||
|
|
||||||
class IdleViewAttachmentForWeb extends IdleDownloadAttachmentForWeb {}
|
|
||||||
|
|
||||||
class StartViewAttachmentForWeb extends StartDownloadAttachmentForWeb {
|
|
||||||
StartViewAttachmentForWeb(super.taskId, super.attachment);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewingAttachmentForWeb extends DownloadingAttachmentForWeb {
|
|
||||||
ViewingAttachmentForWeb(
|
|
||||||
super.taskId,
|
|
||||||
super.attachment,
|
|
||||||
super.progress,
|
|
||||||
super.downloaded,
|
|
||||||
super.total,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewAttachmentForWebSuccess extends DownloadAttachmentForWebSuccess {
|
|
||||||
ViewAttachmentForWebSuccess(super.taskId, super.attachment, super.bytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
class ViewAttachmentForWebFailure extends DownloadAttachmentForWebFailure {
|
|
||||||
ViewAttachmentForWebFailure({
|
|
||||||
required super.attachment,
|
|
||||||
super.taskId,
|
|
||||||
super.exception,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:core/presentation/state/failure.dart';
|
|
||||||
import 'package:core/presentation/state/success.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
|
||||||
import 'package:model/download/download_task_id.dart';
|
|
||||||
import 'package:model/email/attachment.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/view_attachment_for_web_state.dart';
|
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/download_attachment_for_web_interactor.dart';
|
|
||||||
|
|
||||||
class ViewAttachmentForWebInteractor {
|
|
||||||
ViewAttachmentForWebInteractor(this._downloadAttachmentForWebInteractor);
|
|
||||||
|
|
||||||
final DownloadAttachmentForWebInteractor _downloadAttachmentForWebInteractor;
|
|
||||||
|
|
||||||
Stream<Either<Failure, Success>> execute(
|
|
||||||
DownloadTaskId taskId,
|
|
||||||
Attachment attachment,
|
|
||||||
AccountId accountId,
|
|
||||||
String baseDownloadUrl,
|
|
||||||
StreamController<Either<Failure, Success>> onReceiveController,
|
|
||||||
) =>
|
|
||||||
_downloadAttachmentForWebInteractor
|
|
||||||
.execute(
|
|
||||||
taskId,
|
|
||||||
attachment,
|
|
||||||
accountId,
|
|
||||||
baseDownloadUrl,
|
|
||||||
onReceiveController)
|
|
||||||
.map(
|
|
||||||
(result) => result.fold(
|
|
||||||
(failure) {
|
|
||||||
if (failure is DownloadAttachmentForWebFailure) {
|
|
||||||
return Left(ViewAttachmentForWebFailure(
|
|
||||||
attachment: attachment,
|
|
||||||
taskId: failure.taskId,
|
|
||||||
exception: failure.exception,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Left(failure);
|
|
||||||
},
|
|
||||||
(success) {
|
|
||||||
if (success is StartDownloadAttachmentForWeb) {
|
|
||||||
return Right(StartViewAttachmentForWeb(
|
|
||||||
success.taskId,
|
|
||||||
success.attachment,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success is DownloadingAttachmentForWeb) {
|
|
||||||
return Right(ViewingAttachmentForWeb(
|
|
||||||
success.taskId,
|
|
||||||
success.attachment,
|
|
||||||
success.progress,
|
|
||||||
success.downloaded,
|
|
||||||
success.total,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (success is DownloadAttachmentForWebSuccess) {
|
|
||||||
return Right(ViewAttachmentForWebSuccess(
|
|
||||||
success.taskId,
|
|
||||||
success.attachment,
|
|
||||||
success.bytes,
|
|
||||||
));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Right(success);
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,255 +0,0 @@
|
|||||||
import 'dart:async';
|
|
||||||
|
|
||||||
import 'package:core/presentation/state/failure.dart';
|
|
||||||
import 'package:core/presentation/state/success.dart';
|
|
||||||
import 'package:dartz/dartz.dart';
|
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
|
||||||
import 'package:mockito/annotations.dart';
|
|
||||||
import 'package:mockito/mockito.dart';
|
|
||||||
import 'package:model/download/download_task_id.dart';
|
|
||||||
import 'package:model/email/attachment.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/view_attachment_for_web_state.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/view_attachment_for_web_interactor.dart';
|
|
||||||
|
|
||||||
import 'view_attachment_for_web_interactor_test.mocks.dart';
|
|
||||||
|
|
||||||
@GenerateNiceMocks([
|
|
||||||
MockSpec<DownloadAttachmentForWebInteractor>(),
|
|
||||||
MockSpec<Failure>(),
|
|
||||||
MockSpec<Success>(),
|
|
||||||
])
|
|
||||||
void main() {
|
|
||||||
final testDownloadAttachmentForWebInteractor =
|
|
||||||
MockDownloadAttachmentForWebInteractor();
|
|
||||||
final viewAttachmentForWebInteractor =
|
|
||||||
ViewAttachmentForWebInteractor(testDownloadAttachmentForWebInteractor);
|
|
||||||
|
|
||||||
final testDownloadTaskId = DownloadTaskId('123');
|
|
||||||
final testAttachment = Attachment();
|
|
||||||
final testAccountId = AccountId(Id('id'));
|
|
||||||
final testException = TimeoutException('321');
|
|
||||||
const testBaseDownloadUrl = 'base_download_url';
|
|
||||||
final testReceiveController = StreamController<Either<Failure, Success>>();
|
|
||||||
final testFailure = MockFailure();
|
|
||||||
final testSuccess = MockSuccess();
|
|
||||||
final testBytes = Uint8List(12);
|
|
||||||
|
|
||||||
group('View attachment for web interactor', () {
|
|
||||||
test(
|
|
||||||
'should yield ViewAttachmentForWebFailure '
|
|
||||||
'when downloadAttachmentForWebInteractor yield DownloadAttachmentForWebFailure',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer(
|
|
||||||
(_) => Stream.value(
|
|
||||||
Left(
|
|
||||||
DownloadAttachmentForWebFailure(
|
|
||||||
attachment: testAttachment,
|
|
||||||
taskId: testDownloadTaskId,
|
|
||||||
exception: testException,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([
|
|
||||||
Left(
|
|
||||||
ViewAttachmentForWebFailure(
|
|
||||||
attachment: testAttachment,
|
|
||||||
taskId: testDownloadTaskId,
|
|
||||||
exception: testException,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should yield Failure '
|
|
||||||
'when downloadAttachmentForWebInteractor doesn\'t yield DownloadAttachmentForWebFailure',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer((_) => Stream.value(Left(testFailure)));
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([Left(testFailure)]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should yield StartViewAttachmentForWeb '
|
|
||||||
'when downloadAttachmentForWebInteractor yield StartDownloadAttachmentForWeb',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer((_) => Stream.value(
|
|
||||||
Right(StartDownloadAttachmentForWeb(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([
|
|
||||||
Right(StartViewAttachmentForWeb(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
))
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should yield ViewingAttachmentForWeb '
|
|
||||||
'when downloadAttachmentForWebInteractor yield DownloadingAttachmentForWeb',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer(
|
|
||||||
(_) => Stream.fromIterable([
|
|
||||||
Right(DownloadingAttachmentForWeb(testDownloadTaskId, testAttachment, 0.5, 1, 2)),
|
|
||||||
Right(DownloadingAttachmentForWeb(testDownloadTaskId, testAttachment, 1, 1, 2)),
|
|
||||||
Right(DownloadingAttachmentForWeb(testDownloadTaskId, testAttachment, 1, 2, 2)),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([
|
|
||||||
Right(ViewingAttachmentForWeb(testDownloadTaskId, testAttachment, 0.5, 1, 2)),
|
|
||||||
Right(ViewingAttachmentForWeb(testDownloadTaskId, testAttachment, 1, 1, 2)),
|
|
||||||
Right(ViewingAttachmentForWeb(testDownloadTaskId, testAttachment, 1, 2, 2)),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should yield ViewAttachmentForWebSuccess '
|
|
||||||
'when downloadAttachmentForWebInteractor yield DownloadAttachmentForWebSuccess',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer((_) => Stream.value(
|
|
||||||
Right(DownloadAttachmentForWebSuccess(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testBytes,
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([
|
|
||||||
Right(ViewAttachmentForWebSuccess(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testBytes,
|
|
||||||
)),
|
|
||||||
]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should yield Success '
|
|
||||||
'when downloadAttachmentForWebInteractor yield state doesn\'t match any of the above',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(testDownloadAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
)).thenAnswer((_) => Stream.value(Right(testSuccess)));
|
|
||||||
|
|
||||||
// assert
|
|
||||||
expect(
|
|
||||||
viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
testBaseDownloadUrl,
|
|
||||||
testReceiveController,
|
|
||||||
),
|
|
||||||
emitsInOrder([Right(testSuccess)]),
|
|
||||||
);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -2,28 +2,21 @@ import 'dart:ui';
|
|||||||
|
|
||||||
import 'package:core/core.dart';
|
import 'package:core/core.dart';
|
||||||
import 'package:dartz/dartz.dart' hide State;
|
import 'package:dartz/dartz.dart' hide State;
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter_test/flutter_test.dart';
|
import 'package:flutter_test/flutter_test.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:http_parser/http_parser.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/account_id.dart';
|
import 'package:jmap_dart_client/jmap/account_id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
import 'package:jmap_dart_client/jmap/core/capability/calendar_event_capability.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
import 'package:jmap_dart_client/jmap/core/capability/capability_identifier.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/id.dart';
|
import 'package:jmap_dart_client/jmap/core/id.dart';
|
||||||
import 'package:jmap_dart_client/jmap/core/session/session.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/core/state.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/core/user_name.dart';
|
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/calendar_event.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart';
|
import 'package:jmap_dart_client/jmap/mail/calendar/reply/calendar_event_accept_response.dart';
|
||||||
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
import 'package:jmap_dart_client/jmap/mail/email/email.dart';
|
||||||
import 'package:mockito/annotations.dart';
|
import 'package:mockito/annotations.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:model/model.dart';
|
|
||||||
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
import 'package:tmail_ui_user/features/caching/caching_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/model/event_action.dart';
|
import 'package:tmail_ui_user/features/email/domain/model/event_action.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_accept_state.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.dart';
|
import 'package:tmail_ui_user/features/email/domain/state/parse_calendar_event_state.dart';
|
||||||
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/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/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/calendar_event_reject_interactor.dart';
|
||||||
@@ -37,7 +30,6 @@ import 'package:tmail_ui_user/features/email/domain/usecases/move_to_mailbox_int
|
|||||||
import 'package:tmail_ui_user/features/email/domain/usecases/print_email_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/print_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/store_event_attendance_status_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/store_event_attendance_status_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/store_opened_email_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/store_opened_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/view_attachment_for_web_interactor.dart';
|
|
||||||
import 'package:tmail_ui_user/features/email/presentation/controller/email_supervisor_controller.dart';
|
import 'package:tmail_ui_user/features/email/presentation/controller/email_supervisor_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
import 'package:tmail_ui_user/features/email/presentation/controller/single_email_controller.dart';
|
||||||
import 'package:tmail_ui_user/features/email/presentation/model/blob_calendar_event.dart';
|
import 'package:tmail_ui_user/features/email/presentation/model/blob_calendar_event.dart';
|
||||||
@@ -71,7 +63,6 @@ const fallbackGenerators = {
|
|||||||
MockSpec<DownloadAttachmentForWebInteractor>(),
|
MockSpec<DownloadAttachmentForWebInteractor>(),
|
||||||
MockSpec<GetAllIdentitiesInteractor>(),
|
MockSpec<GetAllIdentitiesInteractor>(),
|
||||||
MockSpec<StoreOpenedEmailInteractor>(),
|
MockSpec<StoreOpenedEmailInteractor>(),
|
||||||
MockSpec<ViewAttachmentForWebInteractor>(),
|
|
||||||
MockSpec<MailboxDashBoardController>(fallbackGenerators: fallbackGenerators),
|
MockSpec<MailboxDashBoardController>(fallbackGenerators: fallbackGenerators),
|
||||||
MockSpec<EmailSupervisorController>(fallbackGenerators: fallbackGenerators),
|
MockSpec<EmailSupervisorController>(fallbackGenerators: fallbackGenerators),
|
||||||
MockSpec<DownloadManager>(fallbackGenerators: fallbackGenerators),
|
MockSpec<DownloadManager>(fallbackGenerators: fallbackGenerators),
|
||||||
@@ -91,6 +82,7 @@ const fallbackGenerators = {
|
|||||||
MockSpec<MaybeCalendarEventInteractor>(),
|
MockSpec<MaybeCalendarEventInteractor>(),
|
||||||
MockSpec<RejectCalendarEventInteractor>(),
|
MockSpec<RejectCalendarEventInteractor>(),
|
||||||
MockSpec<StoreEventAttendanceStatusInteractor>(),
|
MockSpec<StoreEventAttendanceStatusInteractor>(),
|
||||||
|
MockSpec<PrintUtils>(),
|
||||||
])
|
])
|
||||||
void main() {
|
void main() {
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
@@ -106,7 +98,6 @@ void main() {
|
|||||||
MockDownloadAttachmentForWebInteractor();
|
MockDownloadAttachmentForWebInteractor();
|
||||||
final getAllIdentitiesInteractor = MockGetAllIdentitiesInteractor();
|
final getAllIdentitiesInteractor = MockGetAllIdentitiesInteractor();
|
||||||
final storeOpenedEmailInteractor = MockStoreOpenedEmailInteractor();
|
final storeOpenedEmailInteractor = MockStoreOpenedEmailInteractor();
|
||||||
final viewAttachmentForWebInteractor = MockViewAttachmentForWebInteractor();
|
|
||||||
final mailboxDashboardController = MockMailboxDashBoardController();
|
final mailboxDashboardController = MockMailboxDashBoardController();
|
||||||
final emailSupervisorController = MockEmailSupervisorController();
|
final emailSupervisorController = MockEmailSupervisorController();
|
||||||
final downloadManager = MockDownloadManager();
|
final downloadManager = MockDownloadManager();
|
||||||
@@ -123,6 +114,7 @@ void main() {
|
|||||||
final uuid = MockUuid();
|
final uuid = MockUuid();
|
||||||
final printEmailInteractor = MockPrintEmailInteractor();
|
final printEmailInteractor = MockPrintEmailInteractor();
|
||||||
final storeEventAttendanceStatusInteractor = MockStoreEventAttendanceStatusInteractor();
|
final storeEventAttendanceStatusInteractor = MockStoreEventAttendanceStatusInteractor();
|
||||||
|
final printUtils = MockPrintUtils();
|
||||||
|
|
||||||
late SingleEmailController singleEmailController;
|
late SingleEmailController singleEmailController;
|
||||||
|
|
||||||
@@ -135,8 +127,6 @@ void main() {
|
|||||||
),
|
),
|
||||||
}, {}, {}, UserName('data'), google, google, google, google, State('1'));
|
}, {}, {}, UserName('data'), google, google, google, google, State('1'));
|
||||||
const testTaskId = 'taskId';
|
const testTaskId = 'taskId';
|
||||||
final testDownloadTaskId = DownloadTaskId(testTaskId);
|
|
||||||
final testBytes = Uint8List(123);
|
|
||||||
|
|
||||||
setUpAll(() {
|
setUpAll(() {
|
||||||
Get.put<MailboxDashBoardController>(mailboxDashboardController);
|
Get.put<MailboxDashBoardController>(mailboxDashboardController);
|
||||||
@@ -157,6 +147,7 @@ void main() {
|
|||||||
Get.put<ImagePaths>(imagePaths);
|
Get.put<ImagePaths>(imagePaths);
|
||||||
Get.put<ResponsiveUtils>(responsiveUtils);
|
Get.put<ResponsiveUtils>(responsiveUtils);
|
||||||
Get.put<Uuid>(uuid);
|
Get.put<Uuid>(uuid);
|
||||||
|
Get.put<PrintUtils>(printUtils);
|
||||||
|
|
||||||
when(mailboxDashboardController.accountId).thenReturn(Rxn(testAccountId));
|
when(mailboxDashboardController.accountId).thenReturn(Rxn(testAccountId));
|
||||||
when(uuid.v4()).thenReturn(testTaskId);
|
when(uuid.v4()).thenReturn(testTaskId);
|
||||||
@@ -174,115 +165,11 @@ void main() {
|
|||||||
downloadAttachmentForWebInteractor,
|
downloadAttachmentForWebInteractor,
|
||||||
getAllIdentitiesInteractor,
|
getAllIdentitiesInteractor,
|
||||||
storeOpenedEmailInteractor,
|
storeOpenedEmailInteractor,
|
||||||
viewAttachmentForWebInteractor,
|
|
||||||
printEmailInteractor,
|
printEmailInteractor,
|
||||||
storeEventAttendanceStatusInteractor,
|
storeEventAttendanceStatusInteractor,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
group('single email controller', () {
|
|
||||||
test(
|
|
||||||
'should call execute on ViewAttachmentForWebInteractor '
|
|
||||||
'when viewAttachmentForWeb is called',
|
|
||||||
() {
|
|
||||||
// arrange
|
|
||||||
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
|
||||||
final testAttachment = Attachment();
|
|
||||||
|
|
||||||
// act
|
|
||||||
singleEmailController.viewAttachmentForWeb(testAttachment);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
verify(viewAttachmentForWebInteractor.execute(
|
|
||||||
any,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
any,
|
|
||||||
any,
|
|
||||||
)).called(1);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should trigger mailboxDashBoardController.deleteDownloadTask & downloadManager.openDownloadedFileWeb'
|
|
||||||
'when attachment mime type is pdf',
|
|
||||||
() async {
|
|
||||||
// arrange
|
|
||||||
const attachmentName = 'test_name.pdf';
|
|
||||||
final testAttachment = Attachment(
|
|
||||||
type: MediaType('application', 'pdf'),
|
|
||||||
name: attachmentName);
|
|
||||||
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
|
||||||
when(viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
any,
|
|
||||||
any,
|
|
||||||
)).thenAnswer((_) => Stream.value(
|
|
||||||
right(ViewAttachmentForWebSuccess(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testBytes,
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
// act
|
|
||||||
singleEmailController.viewAttachmentForWeb(testAttachment);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
await untilCalled(mailboxDashboardController.deleteDownloadTask(any));
|
|
||||||
verify(mailboxDashboardController.deleteDownloadTask(testDownloadTaskId))
|
|
||||||
.called(1);
|
|
||||||
await untilCalled(downloadManager.openDownloadedFileWeb(any, any, any));
|
|
||||||
verify(downloadManager.openDownloadedFileWeb(
|
|
||||||
testBytes,
|
|
||||||
Constant.pdfMimeType,
|
|
||||||
attachmentName,
|
|
||||||
)).called(1);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
test(
|
|
||||||
'should trigger mailboxDashBoardController.deleteDownloadTask & downloadManager.createAnchorElementDownloadFileWeb'
|
|
||||||
'when attachment mime type is not pdf',
|
|
||||||
() async {
|
|
||||||
// arrange
|
|
||||||
const testFileName = 'test_file.txt';
|
|
||||||
final testAttachment = Attachment(name: testFileName);
|
|
||||||
when(mailboxDashboardController.sessionCurrent).thenReturn(testSession);
|
|
||||||
when(viewAttachmentForWebInteractor.execute(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testAccountId,
|
|
||||||
any,
|
|
||||||
any,
|
|
||||||
)).thenAnswer((_) => Stream.value(
|
|
||||||
right(ViewAttachmentForWebSuccess(
|
|
||||||
testDownloadTaskId,
|
|
||||||
testAttachment,
|
|
||||||
testBytes,
|
|
||||||
)),
|
|
||||||
));
|
|
||||||
|
|
||||||
// act
|
|
||||||
singleEmailController.viewAttachmentForWeb(testAttachment);
|
|
||||||
|
|
||||||
// assert
|
|
||||||
await untilCalled(mailboxDashboardController.deleteDownloadTask(any));
|
|
||||||
verify(mailboxDashboardController.deleteDownloadTask(testDownloadTaskId))
|
|
||||||
.called(1);
|
|
||||||
await untilCalled(
|
|
||||||
downloadManager.createAnchorElementDownloadFileWeb(any, any),
|
|
||||||
);
|
|
||||||
verify(downloadManager.createAnchorElementDownloadFileWeb(
|
|
||||||
testBytes,
|
|
||||||
testFileName,
|
|
||||||
)).called(1);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
group('calendar event reply test:', () {
|
group('calendar event reply test:', () {
|
||||||
final blobId = Id('abc123');
|
final blobId = Id('abc123');
|
||||||
final emailId = EmailId(Id('xyz123'));
|
final emailId = EmailId(Id('xyz123'));
|
||||||
|
|||||||
@@ -26,22 +26,35 @@ import 'package:tmail_ui_user/features/login/domain/usecases/update_authenticati
|
|||||||
import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_manager.dart';
|
import 'package:tmail_ui_user/features/manage_account/data/local/language_cache_manager.dart';
|
||||||
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oidc_interactor.dart';
|
||||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||||
|
import 'package:tmail_ui_user/main/utils/email_receive_manager.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import '../../email/presentation/controller/single_email_controller_test.mocks.dart';
|
|
||||||
import '../../mailbox_dashboard/presentation/controller/mailbox_dashboard_controller_test.mocks.dart';
|
|
||||||
import 'home_controller_test.mocks.dart';
|
import 'home_controller_test.mocks.dart';
|
||||||
|
|
||||||
@GenerateNiceMocks([
|
@GenerateNiceMocks([
|
||||||
|
MockSpec<AuthorizationInterceptors>(),
|
||||||
|
MockSpec<DynamicUrlInterceptors>(),
|
||||||
|
MockSpec<DeleteCredentialInteractor>(),
|
||||||
|
MockSpec<LogoutOidcInteractor>(),
|
||||||
|
MockSpec<DeleteAuthorityOidcInteractor>(),
|
||||||
|
MockSpec<AppToast>(),
|
||||||
|
MockSpec<ImagePaths>(),
|
||||||
|
MockSpec<ResponsiveUtils>(),
|
||||||
|
MockSpec<Uuid>(),
|
||||||
MockSpec<CleanupEmailCacheInteractor>(),
|
MockSpec<CleanupEmailCacheInteractor>(),
|
||||||
MockSpec<CleanupRecentSearchCacheInteractor>(),
|
MockSpec<CleanupRecentSearchCacheInteractor>(),
|
||||||
MockSpec<CleanupRecentLoginUrlCacheInteractor>(),
|
MockSpec<CleanupRecentLoginUrlCacheInteractor>(),
|
||||||
MockSpec<CleanupRecentLoginUsernameCacheInteractor>(),
|
MockSpec<CleanupRecentLoginUsernameCacheInteractor>(),
|
||||||
|
MockSpec<EmailReceiveManager>(),
|
||||||
|
MockSpec<GetSessionInteractor>(),
|
||||||
|
MockSpec<GetAuthenticatedAccountInteractor>(),
|
||||||
|
MockSpec<UpdateAuthenticationAccountInteractor>(),
|
||||||
|
MockSpec<CachingManager>(),
|
||||||
|
MockSpec<LanguageCacheManager>(),
|
||||||
])
|
])
|
||||||
void main() {
|
void main() {
|
||||||
TestWidgetsFlutterBinding.ensureInitialized();
|
TestWidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
|
||||||
late HomeController homeController;
|
late HomeController homeController;
|
||||||
late MockCleanupEmailCacheInteractor cleanupEmailCacheInteractor;
|
late MockCleanupEmailCacheInteractor cleanupEmailCacheInteractor;
|
||||||
late MockEmailReceiveManager emailReceiveManager;
|
late MockEmailReceiveManager emailReceiveManager;
|
||||||
@@ -53,8 +66,8 @@ void main() {
|
|||||||
late MockGetAuthenticatedAccountInteractor mockGetAuthenticatedAccountInteractor;
|
late MockGetAuthenticatedAccountInteractor mockGetAuthenticatedAccountInteractor;
|
||||||
late MockUpdateAuthenticationAccountInteractor mockUpdateAuthenticationAccountInteractor;
|
late MockUpdateAuthenticationAccountInteractor mockUpdateAuthenticationAccountInteractor;
|
||||||
|
|
||||||
late CachingManager mockCachingManager;
|
late MockCachingManager mockCachingManager;
|
||||||
late LanguageCacheManager mockLanguageCacheManager;
|
late MockLanguageCacheManager mockLanguageCacheManager;
|
||||||
late MockAuthorizationInterceptors mockAuthorizationInterceptors;
|
late MockAuthorizationInterceptors mockAuthorizationInterceptors;
|
||||||
late MockDynamicUrlInterceptors mockDynamicUrlInterceptors;
|
late MockDynamicUrlInterceptors mockDynamicUrlInterceptors;
|
||||||
late MockDeleteCredentialInteractor mockDeleteCredentialInteractor;
|
late MockDeleteCredentialInteractor mockDeleteCredentialInteractor;
|
||||||
|
|||||||
@@ -35,11 +35,18 @@ import 'package:tmail_ui_user/features/manage_account/domain/usecases/log_out_oi
|
|||||||
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
import 'package:tmail_ui_user/main/bindings/network/binding_tag.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import '../../email/presentation/controller/single_email_controller_test.mocks.dart';
|
|
||||||
import '../../mailbox_dashboard/presentation/controller/mailbox_dashboard_controller_test.mocks.dart';
|
|
||||||
import 'login_controller_test.mocks.dart';
|
import 'login_controller_test.mocks.dart';
|
||||||
|
|
||||||
@GenerateNiceMocks([
|
@GenerateNiceMocks([
|
||||||
|
MockSpec<AuthorizationInterceptors>(),
|
||||||
|
MockSpec<DynamicUrlInterceptors>(),
|
||||||
|
MockSpec<DeleteCredentialInteractor>(),
|
||||||
|
MockSpec<LogoutOidcInteractor>(),
|
||||||
|
MockSpec<DeleteAuthorityOidcInteractor>(),
|
||||||
|
MockSpec<AppToast>(),
|
||||||
|
MockSpec<ImagePaths>(),
|
||||||
|
MockSpec<ResponsiveUtils>(),
|
||||||
|
MockSpec<Uuid>(),
|
||||||
MockSpec<AuthenticationInteractor>(),
|
MockSpec<AuthenticationInteractor>(),
|
||||||
MockSpec<CheckOIDCIsAvailableInteractor>(),
|
MockSpec<CheckOIDCIsAvailableInteractor>(),
|
||||||
MockSpec<GetOIDCIsAvailableInteractor>(),
|
MockSpec<GetOIDCIsAvailableInteractor>(),
|
||||||
@@ -53,6 +60,11 @@ import 'login_controller_test.mocks.dart';
|
|||||||
MockSpec<SaveLoginUsernameOnMobileInteractor>(),
|
MockSpec<SaveLoginUsernameOnMobileInteractor>(),
|
||||||
MockSpec<GetAllRecentLoginUsernameOnMobileInteractor>(),
|
MockSpec<GetAllRecentLoginUsernameOnMobileInteractor>(),
|
||||||
MockSpec<DNSLookupToGetJmapUrlInteractor>(),
|
MockSpec<DNSLookupToGetJmapUrlInteractor>(),
|
||||||
|
MockSpec<GetSessionInteractor>(),
|
||||||
|
MockSpec<GetAuthenticatedAccountInteractor>(),
|
||||||
|
MockSpec<UpdateAuthenticationAccountInteractor>(),
|
||||||
|
MockSpec<CachingManager>(),
|
||||||
|
MockSpec<LanguageCacheManager>(),
|
||||||
])
|
])
|
||||||
void main() {
|
void main() {
|
||||||
late MockAuthenticationInteractor mockAuthenticationInteractor;
|
late MockAuthenticationInteractor mockAuthenticationInteractor;
|
||||||
|
|||||||
+17
-1
@@ -26,6 +26,9 @@ import 'package:tmail_ui_user/features/composer/domain/usecases/update_email_dra
|
|||||||
import 'package:tmail_ui_user/features/email/domain/usecases/delete_email_permanently_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/delete_email_permanently_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/delete_multiple_emails_permanently_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/delete_multiple_emails_permanently_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/get_restored_deleted_message_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/get_restored_deleted_message_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_email_read_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/domain/usecases/mark_as_star_email_interactor.dart';
|
||||||
|
import 'package:tmail_ui_user/features/email/domain/usecases/move_to_mailbox_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/restore_deleted_message_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/restore_deleted_message_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/email/domain/usecases/unsubscribe_email_interactor.dart';
|
import 'package:tmail_ui_user/features/email/domain/usecases/unsubscribe_email_interactor.dart';
|
||||||
import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart';
|
import 'package:tmail_ui_user/features/home/domain/usecases/get_session_interactor.dart';
|
||||||
@@ -92,7 +95,6 @@ import 'package:tmail_ui_user/features/network_connection/presentation/network_c
|
|||||||
if (dart.library.html) 'package:tmail_ui_user/features/network_connection/presentation/web_network_connection_controller.dart';
|
if (dart.library.html) 'package:tmail_ui_user/features/network_connection/presentation/web_network_connection_controller.dart';
|
||||||
import 'package:uuid/uuid.dart';
|
import 'package:uuid/uuid.dart';
|
||||||
|
|
||||||
import '../../../email/presentation/controller/single_email_controller_test.mocks.dart';
|
|
||||||
import 'mailbox_dashboard_controller_test.mocks.dart';
|
import 'mailbox_dashboard_controller_test.mocks.dart';
|
||||||
|
|
||||||
mockControllerCallback() => InternalFinalCallback<void>(callback: () {});
|
mockControllerCallback() => InternalFinalCallback<void>(callback: () {});
|
||||||
@@ -103,6 +105,9 @@ const fallbackGenerators = {
|
|||||||
|
|
||||||
@GenerateNiceMocks([
|
@GenerateNiceMocks([
|
||||||
// write mock specs for unavailable dependencies
|
// write mock specs for unavailable dependencies
|
||||||
|
MockSpec<MoveToMailboxInteractor>(),
|
||||||
|
MockSpec<MarkAsStarEmailInteractor>(),
|
||||||
|
MockSpec<MarkAsEmailReadInteractor>(),
|
||||||
MockSpec<DeleteEmailPermanentlyInteractor>(),
|
MockSpec<DeleteEmailPermanentlyInteractor>(),
|
||||||
MockSpec<MarkAsMailboxReadInteractor>(),
|
MockSpec<MarkAsMailboxReadInteractor>(),
|
||||||
MockSpec<GetComposerCacheOnWebInteractor>(),
|
MockSpec<GetComposerCacheOnWebInteractor>(),
|
||||||
@@ -153,6 +158,17 @@ const fallbackGenerators = {
|
|||||||
MockSpec<LoadMoreEmailsInMailboxInteractor>(),
|
MockSpec<LoadMoreEmailsInMailboxInteractor>(),
|
||||||
MockSpec<SearchEmailInteractor>(),
|
MockSpec<SearchEmailInteractor>(),
|
||||||
MockSpec<SearchMoreEmailInteractor>(),
|
MockSpec<SearchMoreEmailInteractor>(),
|
||||||
|
MockSpec<AuthorizationInterceptors>(),
|
||||||
|
MockSpec<DynamicUrlInterceptors>(),
|
||||||
|
MockSpec<DeleteCredentialInteractor>(),
|
||||||
|
MockSpec<LogoutOidcInteractor>(),
|
||||||
|
MockSpec<DeleteAuthorityOidcInteractor>(),
|
||||||
|
MockSpec<AppToast>(),
|
||||||
|
MockSpec<ImagePaths>(),
|
||||||
|
MockSpec<ResponsiveUtils>(),
|
||||||
|
MockSpec<Uuid>(),
|
||||||
|
MockSpec<CachingManager>(),
|
||||||
|
MockSpec<LanguageCacheManager>(),
|
||||||
])
|
])
|
||||||
void main() {
|
void main() {
|
||||||
// mock mailbox dashboard controller direct dependencies
|
// mock mailbox dashboard controller direct dependencies
|
||||||
|
|||||||
Reference in New Issue
Block a user