From 4afc9d171136fa65e1d221909214c9119e852d1b Mon Sep 17 00:00:00 2001 From: Pedro Silva <9375141+pedrox-hs@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:46:17 -0300 Subject: [PATCH 1/4] Bump mocktail and mocktail_image_network --- pubspec.lock | 12 +++++++----- pubspec.yaml | 8 ++++++-- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pubspec.lock b/pubspec.lock index e5abfab03..804d34f92 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -991,14 +991,16 @@ packages: name: mocktail url: "https://pub.dartlang.org" source: hosted - version: "0.3.0" + version: "1.0.0" mocktail_image_network: dependency: "direct dev" description: - name: mocktail_image_network - url: "https://pub.dartlang.org" - source: hosted - version: "0.3.1" + path: "packages/mocktail_image_network" + ref: HEAD + resolved-ref: "2fd21e9e7b4447907eb34428fbb8133c5976a90c" + url: "https://github.com/pedrox-hs/mocktail.git" + source: git + version: "1.1.0" nested: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 81df1389a..61f8ae67b 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -97,8 +97,8 @@ dev_dependencies: json_serializable: ^6.3.1 lint: ^1.8.1 mobx_codegen: ^2.0.4 - mocktail: ^0.3.0 - mocktail_image_network: ^0.3.1 + mocktail: ^1.0.0 + mocktail_image_network: ^1.1.0 plugin_platform_interface: ^2.0.0 dependency_overrides: @@ -128,6 +128,10 @@ dependency_overrides: git: url: https://github.com/pedrox-hs/flutter_tags.git ref: null-safety + mocktail_image_network: + git: + url: https://github.com/pedrox-hs/mocktail.git + path: packages/mocktail_image_network smooth_star_rating: git: url: https://github.com/bhavin-concetto/smoothratingbar.git From bf4d668f0fa1299306ffeda4d89b80f88e300a71 Mon Sep 17 00:00:00 2001 From: Pedro Silva <9375141+pedrox-hs@users.noreply.github.com> Date: Sat, 2 Mar 2024 20:29:42 -0300 Subject: [PATCH 2/4] Add tests for ChatMainTalksPage --- .../chat/presentation/chat_main_module.dart | 2 +- .../talk/chat_main_talks_controller.dart | 18 +- .../talk/chat_main_talks_controller.g.dart | 13 +- .../talk/chat_main_talks_page.dart | 2 +- .../talk/chat_main_talks_page_test.dart | 199 ++++++++++++++++++ .../ci/chat_main_talks_page_error_state.png | Bin 0 -> 7854 bytes .../ci/chat_main_talks_page_initial_state.png | Bin 0 -> 9812 bytes test/utils/module_testing.dart | 21 ++ 8 files changed, 236 insertions(+), 19 deletions(-) create mode 100644 test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart create mode 100644 test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_error_state.png create mode 100644 test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_initial_state.png diff --git a/lib/app/features/chat/presentation/chat_main_module.dart b/lib/app/features/chat/presentation/chat_main_module.dart index 6f085fa18..9f19934e4 100644 --- a/lib/app/features/chat/presentation/chat_main_module.dart +++ b/lib/app/features/chat/presentation/chat_main_module.dart @@ -27,7 +27,7 @@ class ChatMainModule extends WidgetModule { modulesServices: i.get(), ), ), - Bind.factory( + Bind.factory( (i) => ChatMainTalksController( chatChannelRepository: i.get(), ), diff --git a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart index 7ba5f91a9..fc95ea368 100644 --- a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart +++ b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart @@ -14,15 +14,13 @@ import '../../domain/states/chat_main_talks_state.dart'; part 'chat_main_talks_controller.g.dart'; -class ChatMainTalksController extends _ChatMainTalksControllerBase - with _$ChatMainTalksController { - ChatMainTalksController({ - required IChatChannelRepository chatChannelRepository, - }) : super(chatChannelRepository); -} +class ChatMainTalksController = IChatMainTalksController + with _$ChatMainTalksController; -abstract class _ChatMainTalksControllerBase with Store, MapFailureMessage { - _ChatMainTalksControllerBase(this._chatChannelRepository) { +abstract class IChatMainTalksController with Store, MapFailureMessage { + IChatMainTalksController({ + required IChatChannelRepository chatChannelRepository, + }) : _chatChannelRepository = chatChannelRepository { _init(); } @@ -68,7 +66,7 @@ abstract class _ChatMainTalksControllerBase with Store, MapFailureMessage { } } -extension _ChatMainTalksControllerBasePrivate on _ChatMainTalksControllerBase { +extension _ChatMainTalksControllerBasePrivate on IChatMainTalksController { Future forwardToChat(ChatChannelOpenEntity session) async { return Modular.to .pushNamed('/mainboard/chat/${session.token}', arguments: session) @@ -134,7 +132,7 @@ extension _ChatMainTalksControllerBasePrivate on _ChatMainTalksControllerBase { tiles.add(ChatMainAssistantCardTile(cards: cards)); } - if (session.channels!.isNotEmpty) { + if (session.channels?.isNotEmpty == true) { final total = session.channels!.length; final title = total > 1 ? 'Suas conversas ($total)' : 'Sua conversa'; tiles.add(ChatMainChannelHeaderTile(title: title)); diff --git a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.g.dart b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.g.dart index e7de30686..e9576623e 100644 --- a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.g.dart +++ b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.g.dart @@ -8,9 +8,9 @@ part of 'chat_main_talks_controller.dart'; // ignore_for_file: non_constant_identifier_names, unnecessary_brace_in_string_interps, unnecessary_lambdas, prefer_expression_function_bodies, lines_longer_than_80_chars, avoid_as, avoid_annotating_with_dynamic -mixin _$ChatMainTalksController on _ChatMainTalksControllerBase, Store { +mixin _$ChatMainTalksController on IChatMainTalksController, Store { final _$_fetchProgressAtom = - Atom(name: '_ChatMainTalksControllerBase._fetchProgress'); + Atom(name: 'IChatMainTalksController._fetchProgress'); @override ObservableFuture>? @@ -28,7 +28,7 @@ mixin _$ChatMainTalksController on _ChatMainTalksControllerBase, Store { } final _$currentStateAtom = - Atom(name: '_ChatMainTalksControllerBase.currentState'); + Atom(name: 'IChatMainTalksController.currentState'); @override ChatMainTalksState get currentState { @@ -43,8 +43,7 @@ mixin _$ChatMainTalksController on _ChatMainTalksControllerBase, Store { }); } - final _$reloadAsyncAction = - AsyncAction('_ChatMainTalksControllerBase.reload'); + final _$reloadAsyncAction = AsyncAction('IChatMainTalksController.reload'); @override Future reload() { @@ -52,7 +51,7 @@ mixin _$ChatMainTalksController on _ChatMainTalksControllerBase, Store { } final _$openChannelAsyncAction = - AsyncAction('_ChatMainTalksControllerBase.openChannel'); + AsyncAction('IChatMainTalksController.openChannel'); @override Future openChannel(ChatChannelEntity channel) { @@ -60,7 +59,7 @@ mixin _$ChatMainTalksController on _ChatMainTalksControllerBase, Store { } final _$openAssistantCardAsyncAction = - AsyncAction('_ChatMainTalksControllerBase.openAssistantCard'); + AsyncAction('IChatMainTalksController.openAssistantCard'); @override Future openAssistantCard(ChatMainSupportTile data) { diff --git a/lib/app/features/chat/presentation/talk/chat_main_talks_page.dart b/lib/app/features/chat/presentation/talk/chat_main_talks_page.dart index ea174e9aa..7b1c3fef1 100644 --- a/lib/app/features/chat/presentation/talk/chat_main_talks_page.dart +++ b/lib/app/features/chat/presentation/talk/chat_main_talks_page.dart @@ -19,7 +19,7 @@ class ChatMainTalksPage extends StatefulWidget { } class _ChatMainTalksPageState - extends ModularState { + extends ModularState { @override Widget build(BuildContext context) { return Container( diff --git a/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart b/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart new file mode 100644 index 000000000..b0429712a --- /dev/null +++ b/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart @@ -0,0 +1,199 @@ +import 'package:dartz/dartz.dart' show right, left; +import 'package:flutter_modular/flutter_modular.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; +import 'package:flutter_test/flutter_test.dart'; +import 'package:mocktail/mocktail.dart'; +import 'package:mocktail_image_network/mocktail_image_network.dart'; +import 'package:penhas/app/core/error/failures.dart'; +import 'package:penhas/app/features/appstate/domain/entities/app_state_entity.dart'; +import 'package:penhas/app/features/chat/domain/entities/chat_assistant_entity.dart'; +import 'package:penhas/app/features/chat/domain/entities/chat_channel_available_entity.dart'; +import 'package:penhas/app/features/chat/domain/entities/chat_channel_entity.dart'; +import 'package:penhas/app/features/chat/domain/entities/chat_channel_open_entity.dart'; +import 'package:penhas/app/features/chat/domain/entities/chat_user_entity.dart'; +import 'package:penhas/app/features/chat/domain/repositories/chat_channel_repository.dart'; +import 'package:penhas/app/features/chat/presentation/chat_main_module.dart'; +import 'package:penhas/app/features/chat/presentation/talk/chat_main_talks_page.dart'; + +import '../../../../../utils/golden_tests.dart'; +import '../../../../../utils/module_testing.dart'; + +void main() { + group(ChatMainTalksPage, () { + late IChatChannelRepository mockRepository; + late IModularNavigator mockNavigator; + + setUp(() { + mockRepository = _MockChatChannelRepository(); + Modular.navigatorDelegate = mockNavigator = _MockModularNavigate(); + + loadModules( + [ChatMainModule()], + overrides: [ + Bind((i) => mockRepository), + ], + ); + + when(() => mockRepository.listChannel()).thenAnswer( + (_) async => right(_chatChannelAvailabelFixture), + ); + }); + + screenshotTest( + 'loaded state should be rendered', + fileName: 'chat_main_talks_page_initial_state', + pageBuilder: () => ChatMainTalksPage(), + ); + + screenshotTest( + 'error state should be rendered', + fileName: 'chat_main_talks_page_error_state', + pageBuilder: () => ChatMainTalksPage(), + setUp: () { + when(() => mockRepository.listChannel()).thenAnswer( + (_) async => left(ServerFailure()), + ); + }, + ); + + testWidgets( + 'should navigate to assistant quiz when open assistant card', + (tester) => mockNetworkImages(() async { + // arrange + final widget = buildTestableWidget(ChatMainTalksPage()); + await tester.pumpWidget(widget); + await tester.pumpAndSettle(); + when( + () => mockNavigator.popAndPushNamed( + any(), + arguments: any(named: 'arguments'), + ), + ).thenAnswer((_) => Future.value()); + + // act + await tester.tap(find.text('Assistente PenhaS')); + + // assert + verify( + () => mockNavigator.popAndPushNamed( + '/quiz', + arguments: QuizSessionEntity( + sessionId: 'assistant-quiz-session', + ), + ), + ).called(1); + }), + ); + + testWidgets( + 'should navigate to support chat when open support card', + (tester) => mockNetworkImages(() async { + // arrange + final widget = buildTestableWidget(ChatMainTalksPage()); + await tester.pumpWidget(widget); + await tester.pumpAndSettle(); + when( + () => mockNavigator.pushNamed( + any(), + arguments: any(named: 'arguments'), + ), + ).thenAnswer((_) => Future.value(true)); + + // act + await tester.tap(find.text('Suporte PenhaS')); + + // assert + // verifyZeroInteractions(mockNavigator); + verify( + () => mockNavigator.pushNamed( + '/mainboard/chat/support-channel', + arguments: ChatChannelOpenEntity(token: 'support-channel'), + ), + ).called(1); + }), + ); + + testWidgets( + 'should navigate to chat page when open conversation card', + (tester) => mockNetworkImages(() async { + // arrange + final widget = buildTestableWidget(ChatMainTalksPage()); + await tester.pumpWidget(widget); + await tester.pumpAndSettle(); + when( + () => mockNavigator.pushNamed( + any(), + arguments: any(named: 'arguments'), + ), + ).thenAnswer((_) => Future.value(true)); + + // act + await tester.tap(find.text('Mary')); + + // assert + verify( + () => mockNavigator.pushNamed( + '/mainboard/chat/talk-with-mary', + arguments: ChatChannelOpenEntity(token: 'talk-with-mary'), + ), + ).called(1); + }), + ); + }); +} + +class _MockModularNavigate extends Mock implements IModularNavigator {} + +class _MockChatChannelRepository extends Mock + implements IChatChannelRepository {} + +final _chatChannelAvailabelFixture = ChatChannelAvailableEntity( + assistant: ChatAssistantEntity( + avatar: null, + quizSession: QuizSessionEntity( + sessionId: 'assistant-quiz-session', + ), + title: 'Assistente PenhaS', + subtitle: 'Entenda como posso te ajudar', + ), + support: ChatChannelEntity( + token: 'support-channel', + lastMessageIsMime: false, + lastMessageTime: DateTime.parse('2024-03-02'), + user: ChatUserEntity( + userId: null, + activity: null, + blockedMe: false, + avatar: null, + nickname: 'Suporte PenhaS', + ), + ), + channels: [ + ChatChannelEntity( + token: 'talk-with-mary', + lastMessageIsMime: false, + lastMessageTime: DateTime.parse('2024-03-02'), + user: ChatUserEntity( + userId: null, + activity: 'Ativo', + blockedMe: false, + avatar: 'http://example.com/avatar.svg', + nickname: 'Mary', + ), + ), + ChatChannelEntity( + token: 'talk-with-annie', + lastMessageIsMime: false, + lastMessageTime: DateTime.parse('2024-03-02'), + user: ChatUserEntity( + userId: null, + activity: 'Há 1 minuto', + blockedMe: true, + avatar: 'http://example.com/avatar.svg', + nickname: 'Annie', + ), + ), + ], + hasMore: false, + nextPage: null, +); diff --git a/test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_error_state.png b/test/app/features/chat/presentation/talk/goldens/ci/chat_main_talks_page_error_state.png new file mode 100644 index 0000000000000000000000000000000000000000..4e51bac598dd5c4e3d204a6d85349f6979b84ef6 GIT binary patch literal 7854 zcmeHMe^Aq97=O1R!a$^>ROE*WDwnnPyN0-D^#4@+=r zmI<@FRPw|LBElNPH^I0Lfv!1`=Hfe->|p$u;Z8zyJ@4YI)9Gyo6Y2Q=^WHYT@AJIR z^Lakc=Y7au&t5f+KAVmZn#PISA`;Ri#z;+Y|=tm zQFicT*lo>2$TNl&_Igx$QIB#7$6G_mQMJc+S35LZbR)v|Uqrd9QhVQ+%KE}#(6%&E zj!c7029^-oniV}A zuY!*mzfxdbvF11pfBY(9D*k$j&OL zv*mu6e6go_cZcD2R3VCI2G`t8m?aYBgbd$Wr+*%C1R6RTzRY?M40EljS8pNj7zPzD zeTZ~>hX?glK0}$UwkWt$LM52#T>~waZ}~`K%=KmRMN8m58Pz9n!DMhIgX8R`rNmxU zs}q?NQBqw;n+t$quKLA?+r~2wm7n+8$fQ@UNb7u2@`ir6K5TSQ#S;~{RN z-_d5@wHuf;Q8;Edy>3yk6cJ~h>q2BfF}p;?3zRQK zi0qT}Vd43BAvda%Leazfx>LEixd|2RSC*0~jq22ZVz%CKV+7Wbq`W=FuYTEDy<_?e zVS$FLd;$CNkedAK7_Vk_(>cecb63D)1S;6_s!L>oG06qR2h0Td;iOXxaLNIsYs_L{ zUlNE`L0kQ)6z!{n#=>_nMuf!K8&ZiTISS-j8uDy5OuTsce(8eT@hEGL0 zd!ds+e)Qxi5h_~%39JbgOQ`^n2bW8&xaRF0zxU>-?s>!|-2KxxsCJhT-+jV^PpVI! z0@y_0u=(%_5i0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 5e07be294..a18c250cb 100644 --- a/test/utils/module_testing.dart +++ b/test/utils/module_testing.dart @@ -1,9 +1,30 @@ import 'package:flutter/material.dart'; import 'package:flutter_modular/flutter_modular.dart'; import 'package:flutter_modular/src/presenters/navigation/modular_route_information_parser.dart'; +import 'package:flutter_modular_test/flutter_modular_test.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:penhas/app/app_module.dart'; +import 'aditional_bind_module.dart'; + +void loadModules( + List modules, { + List overrides = const [], +}) { + modules = [ + AditionalBindModule(binds: overrides), + ...modules, + ]; + initModules( + modules, + replaceBinds: overrides, + ); + + addTearDown(() { + modules.forEach(Modular.removeModule); + }); +} + Widget buildTestableApp({ Widget? home, String? initialRoute, From b9cfdf724b1fd565561a6f47823c5ae45c844af1 Mon Sep 17 00:00:00 2001 From: Pedro Silva <9375141+pedrox-hs@users.noreply.github.com> Date: Sun, 3 Mar 2024 17:51:44 -0300 Subject: [PATCH 3/4] Improve conditional readability --- .../chat/presentation/talk/chat_main_talks_controller.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart index fc95ea368..f15ddcccb 100644 --- a/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart +++ b/lib/app/features/chat/presentation/talk/chat_main_talks_controller.dart @@ -132,7 +132,7 @@ extension _ChatMainTalksControllerBasePrivate on IChatMainTalksController { tiles.add(ChatMainAssistantCardTile(cards: cards)); } - if (session.channels?.isNotEmpty == true) { + if (session.channels?.isEmpty == false) { final total = session.channels!.length; final title = total > 1 ? 'Suas conversas ($total)' : 'Sua conversa'; tiles.add(ChatMainChannelHeaderTile(title: title)); From 1af4d0fda791d0286724ea7bfacfed9de6decf88 Mon Sep 17 00:00:00 2001 From: Pedro Silva <9375141+pedrox-hs@users.noreply.github.com> Date: Sun, 3 Mar 2024 18:02:15 -0300 Subject: [PATCH 4/4] Update ChatMainTalksPage tests --- .../chat/presentation/talk/chat_main_talks_page_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart b/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart index b0429712a..b8e38187b 100644 --- a/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart +++ b/test/app/features/chat/presentation/talk/chat_main_talks_page_test.dart @@ -76,7 +76,7 @@ void main() { // assert verify( () => mockNavigator.popAndPushNamed( - '/quiz', + '/quiz?origin=chat', arguments: QuizSessionEntity( sessionId: 'assistant-quiz-session', ),