diff --git a/lib/presentation/mixins/chat_list_item_mixin.dart b/lib/presentation/mixins/chat_list_item_mixin.dart index 9b3642100..ee65ee081 100644 --- a/lib/presentation/mixins/chat_list_item_mixin.dart +++ b/lib/presentation/mixins/chat_list_item_mixin.dart @@ -231,9 +231,6 @@ mixin ChatListItemMixin { room: room, ); } - if (room.notificationCount > 0) { - return Theme.of(context).colorScheme.primary; - } return Colors.transparent; } diff --git a/test/mixin/chat/chat_list_item_mixin_test.dart b/test/mixin/chat/chat_list_item_mixin_test.dart index c2be389cf..160825122 100644 --- a/test/mixin/chat/chat_list_item_mixin_test.dart +++ b/test/mixin/chat/chat_list_item_mixin_test.dart @@ -26,155 +26,144 @@ void main() { chatListItemMixinTest = ChatListItemMixinTest(); }); - testWidgets( - 'WHEN notification count is zero\n' - 'AND room is unmuted\n' - 'THEN color should have transparent\n', ( - WidgetTester tester, - ) async { - when(room.notificationCount).thenReturn(0); - when(room.pushRuleState).thenReturn(PushRuleState.notify); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Colors.transparent); + group('Test highlight message and invitation', () { + testWidgets( + 'WHEN group is invite\n' + 'THEN color should have color primary\n', ( + WidgetTester tester, + ) async { + when(room.membership).thenReturn(Membership.invite); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, Theme.of(context).colorScheme.primary); + }); + + testWidgets( + 'WHEN has new message with mention\n' + 'AND highlight count is greater than zero\n' + 'AND pushRuleState is notify\n' + 'THEN color should be primary\n', ( + WidgetTester tester, + ) async { + when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); + when(room.highlightCount).thenReturn(1); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, Theme.of(context).colorScheme.primary); + }); }); - testWidgets( - 'WHEN group is invite\n' - 'THEN color should have color primary\n', ( - WidgetTester tester, - ) async { - when(room.membership).thenReturn(Membership.invite); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Theme.of(context).colorScheme.primary); - }); - - testWidgets( - 'WHEN notification count is greater than zero\n' - 'AND room is unmuted\n' - 'THEN color should be primary\n', ( - WidgetTester tester, - ) async { - when(room.notificationCount).thenReturn(5); - when(room.pushRuleState).thenReturn(PushRuleState.notify); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Theme.of(context).colorScheme.primary); - }); - - testWidgets( - 'WHEN notification count is greater than zero\n' - 'AND room is muted\n' - 'THEN color should be tertiary[30]\n', ( - WidgetTester tester, - ) async { - when(room.notificationCount).thenReturn(5); - when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, LinagoraRefColors.material().tertiary[30]); - }); - - testWidgets( - 'WHEN marked unread for room\n' - 'THEN color should be primary]\n', ( - WidgetTester tester, - ) async { - when(room.markedUnread).thenReturn(true); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Theme.of(context).colorScheme.primary); - }); - - testWidgets( - 'WHEN has new message \n' - 'AND room is muted\n' - 'THEN color should be tertiary[30]\n', ( - WidgetTester tester, - ) async { - when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); - when(room.hasNewMessages).thenReturn(true); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, LinagoraRefColors.material().tertiary[30]); - }); - - testWidgets( - 'WHEN has new message \n' - 'AND room is muted\n' - 'THEN color should be tertiary[30]\n', ( - WidgetTester tester, - ) async { - when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); - when(room.hasNewMessages).thenReturn(true); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, LinagoraRefColors.material().tertiary[30]); - }); - - testWidgets( - 'WHEN has new message with mention\n' - 'AND highlight count is greater than zero\n' - 'AND room is muted\n' - 'THEN color should be primary\n', ( - WidgetTester tester, - ) async { - when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); - when(room.highlightCount).thenReturn(1); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Theme.of(context).colorScheme.primary); + group('Test room has new message', () { + testWidgets( + 'WHEN notification count is zero\n' + 'AND pushRuleState is notify\n' + 'THEN color should have transparent\n', ( + WidgetTester tester, + ) async { + when(room.notificationCount).thenReturn(0); + when(room.pushRuleState).thenReturn(PushRuleState.notify); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, Colors.transparent); + }); + + testWidgets( + 'WHEN notification count is greater than zero\n' + 'AND pushRuleState is notify\n' + 'THEN color should be primary\n', ( + WidgetTester tester, + ) async { + when(room.notificationCount).thenReturn(5); + when(room.pushRuleState).thenReturn(PushRuleState.notify); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, Theme.of(context).colorScheme.primary); + }); + + testWidgets( + 'WHEN notification count is greater than zero\n' + 'AND pushRuleState is mentionsOnly\n' + 'THEN color should be tertiary[30]\n', ( + WidgetTester tester, + ) async { + when(room.notificationCount).thenReturn(5); + when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, LinagoraRefColors.material().tertiary[30]); + }); + + testWidgets( + 'WHEN has new message \n' + 'AND pushRuleState is mentionsOnly\n' + 'THEN color should be tertiary[30]\n', ( + WidgetTester tester, + ) async { + when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); + when(room.hasNewMessages).thenReturn(true); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, LinagoraRefColors.material().tertiary[30]); + }); }); - testWidgets( - 'WHEN has new message with mention\n' - 'AND highlight count is greater than zero\n' - 'AND room is muted\n' - 'THEN color should be primary\n', ( - WidgetTester tester, - ) async { - when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); - when(room.highlightCount).thenReturn(1); - - final color = chatListItemMixinTest.notificationColor( - context: context, - room: room, - ); - - expect(color, Theme.of(context).colorScheme.primary); + group('Test room is mark as unread', () { + testWidgets( + 'WHEN marked unread for room\n' + 'AND pushRuleState is notify\n' + 'THEN color should be primary]\n', ( + WidgetTester tester, + ) async { + when(room.markedUnread).thenReturn(true); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, Theme.of(context).colorScheme.primary); + }); + + testWidgets( + 'WHEN marked unread for room\n' + 'AND pushRuleState is mentionsOnly\n' + 'THEN color should be primary]\n', ( + WidgetTester tester, + ) async { + when(room.markedUnread).thenReturn(true); + when(room.pushRuleState).thenReturn(PushRuleState.mentionsOnly); + + final color = chatListItemMixinTest.notificationColor( + context: context, + room: room, + ); + + expect(color, LinagoraRefColors.material().tertiary[30]); + }); }); }); }