Skip to content

Commit

Permalink
fixup! fixup! TW-2154: Fix no counter of unread messages for muted chats
Browse files Browse the repository at this point in the history
  • Loading branch information
nqhhdev committed Nov 27, 2024
1 parent b062689 commit 6acbeca
Show file tree
Hide file tree
Showing 2 changed files with 134 additions and 148 deletions.
3 changes: 0 additions & 3 deletions lib/presentation/mixins/chat_list_item_mixin.dart
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ mixin ChatListItemMixin {
room: room,
);
}
if (room.notificationCount > 0) {
return Theme.of(context).colorScheme.primary;
}
return Colors.transparent;
}

Expand Down
279 changes: 134 additions & 145 deletions test/mixin/chat/chat_list_item_mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
});
});
}

0 comments on commit 6acbeca

Please sign in to comment.