diff --git a/integration_test/robots/chat_list_robot.dart b/integration_test/robots/chat_list_robot.dart index 45ba3e50fb..320c171f83 100644 --- a/integration_test/robots/chat_list_robot.dart +++ b/integration_test/robots/chat_list_robot.dart @@ -33,6 +33,14 @@ class ChatListRobot extends HomeRobot { return $(ChatListBottomNavigator).$(InkWell).containing($("Unpin")); } + PatrolFinder getMuteIcon(){ + return $(ChatListBottomNavigator).$(InkWell).containing($("Mute")); + } + + PatrolFinder getUnmuteIcon(){ + return $(ChatListBottomNavigator).$(InkWell).containing($("Unmute")); + } + Future clickOnPenIcon() async{ await getPenIcon().tap(); await $.waitUntilVisible($(AppBar).$("New chat")); @@ -48,6 +56,16 @@ class ChatListRobot extends HomeRobot { await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getUnPinIcon()); } + Future clickOnMuteIcon() async { + await getMuteIcon().tap(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getMuteIcon()); + } + + Future clickOnUnMuteIcon() async { + await getUnmuteIcon().tap(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getUnmuteIcon()); + } + Future openChatGroupByIndex(int index) async { await (await getListOfChatGroup())[index].root.tap(); await $.pumpAndSettle(); diff --git a/integration_test/robots/twake_list_item_robot.dart b/integration_test/robots/twake_list_item_robot.dart index 24c9fb4e7f..5ebc6aa939 100644 --- a/integration_test/robots/twake_list_item_robot.dart +++ b/integration_test/robots/twake_list_item_robot.dart @@ -15,7 +15,7 @@ class TwakeListItemRobot extends CoreRobot { } PatrolFinder getCheckBox() { - return root.$(Checkbox).at(0); + return root.$(Checkbox); } PatrolFinder getTitle() { @@ -45,6 +45,12 @@ class TwakeListItemRobot extends CoreRobot { return $(pinFinder); } + PatrolFinder getMutedIcon(){ + final title = root.$(ChatListItemTitle); + const pinData = IconData(0xF4A7, fontFamily: 'MaterialIcons'); + return $(find.descendant(of: title, matching: find.byIcon(pinData))); + } + int getUnreadMessage(){ final animated = find.descendant( of: root, diff --git a/integration_test/scenarios/chat_scenario.dart b/integration_test/scenarios/chat_scenario.dart index c8b2eb2e8f..2998693481 100644 --- a/integration_test/scenarios/chat_scenario.dart +++ b/integration_test/scenarios/chat_scenario.dart @@ -488,29 +488,60 @@ class ChatScenario extends BaseScenario { return pin.visible; } + bool isMutedAChat(TwakeListItemRobot takeListItem) { + final muted = takeListItem.getMutedIcon(); + return muted.visible; + } + Future pinAChat(String title) async { final twakeListItem = ChatListRobot($).getChatGroupByTitle(title); - ChatListRobot($).scrollUntilVisible($, twakeListItem.root); + await $.tester.ensureVisible(twakeListItem.root); if(!isPinAChat(twakeListItem)) { - await $.tester.ensureVisible(twakeListItem.root); await twakeListItem.root.longPress(); await $.waitUntilVisible(twakeListItem.getCheckBox()); await ChatListRobot($).clickOnPinIcon(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getChatGroupByTitle(title).getCheckBox()); } } Future unPinAChat(String title) async { final twakeListItem = ChatListRobot($).getChatGroupByTitle(title); - ChatListRobot($).scrollUntilVisible($, twakeListItem.root); + await $.tester.ensureVisible(twakeListItem.root); if(isPinAChat(twakeListItem)) { - await $.tester.ensureVisible(twakeListItem.root); await twakeListItem.root.longPress(); await $.waitUntilVisible(twakeListItem.getCheckBox()); await ChatListRobot($).clickOnUnPinIcon(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getChatGroupByTitle(title).getCheckBox()); + } + } + + Future muteAChat(String title) async { + final twakeListItem = ChatListRobot($).getChatGroupByTitle(title); + await $.tester.ensureVisible(twakeListItem.root); + + if(!isMutedAChat(twakeListItem)) + { + await twakeListItem.root.longPress(); + await $.waitUntilVisible(twakeListItem.getCheckBox()); + await ChatListRobot($).clickOnMuteIcon(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getChatGroupByTitle(title).getCheckBox()); + } + } + + Future unmuteAChat(String title) async { + final twakeListItem = ChatListRobot($).getChatGroupByTitle(title); + await $.tester.ensureVisible(twakeListItem.root); + + if(isMutedAChat(twakeListItem)) + { + await twakeListItem.root.longPress(); + await $.waitUntilVisible(twakeListItem.getCheckBox()); + await ChatListRobot($).clickOnUnMuteIcon(); + await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getChatGroupByTitle(title).getCheckBox()); } } @@ -520,4 +551,11 @@ class ChatScenario extends BaseScenario { final exists = isPinAChat(twakeListItem); expect(exists, isPin, reason: 'Expected pin=$isPin but got $exists for "$title"'); } + + Future verifyAChatIsMuted(String title, bool isMuted) async { + final twakeListItem = ChatListRobot($).getChatGroupByTitle(title); + await $.tester.ensureVisible(twakeListItem.root); + final exists = isMutedAChat(twakeListItem); + expect(exists, isMuted, reason: 'Expected pin=$isMuted but got $exists for "$title"'); + } } diff --git a/integration_test/tests/chat/chat_list_test.dart b/integration_test/tests/chat/chat_list_test.dart index 17a825fa95..5dadb7b318 100644 --- a/integration_test/tests/chat/chat_list_test.dart +++ b/integration_test/tests/chat/chat_list_test.dart @@ -88,17 +88,25 @@ void main() { description: 'Pin/unpin a chat', test: ($) async { const groupTest = String.fromEnvironment('GroupTest'); - // goto chat screen await HomeRobot($).gotoChatListScreen(); - // pin a chat await ChatScenario($).pinAChat(groupTest); - // verify the chat is pin await ChatScenario($).verifyAChatIsPin(groupTest, true); - - // unpin a chat + await ChatScenario($).unPinAChat(groupTest); - // verify the chat is unPin await ChatScenario($).verifyAChatIsPin(groupTest, false); }, ); + + TestBase().runPatrolTest( + description: 'Mute/unmute a chat', + test: ($) async { + const groupTest = String.fromEnvironment('TitleOfGroupTest'); + await HomeRobot($).gotoChatListScreen(); + await ChatScenario($).muteAChat(groupTest); + await ChatScenario($).verifyAChatIsMuted(groupTest, true); + + await ChatScenario($).unmuteAChat(groupTest); + await ChatScenario($).verifyAChatIsMuted(groupTest, false); + }, + ); }