Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions integration_test/robots/chat_list_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> clickOnPenIcon() async{
await getPenIcon().tap();
await $.waitUntilVisible($(AppBar).$("New chat"));
Expand All @@ -48,6 +56,16 @@ class ChatListRobot extends HomeRobot {
await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getUnPinIcon());
}

Future<void> clickOnMuteIcon() async {
await getMuteIcon().tap();
await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getMuteIcon());
}

Future<void> clickOnUnMuteIcon() async {
await getUnmuteIcon().tap();
await ChatListRobot($).waitUntilAbsent($, ChatListRobot($).getUnmuteIcon());
}

Future<ChatGroupDetailRobot> openChatGroupByIndex(int index) async {
await (await getListOfChatGroup())[index].root.tap();
await $.pumpAndSettle();
Expand Down
8 changes: 7 additions & 1 deletion integration_test/robots/twake_list_item_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class TwakeListItemRobot extends CoreRobot {
}

PatrolFinder getCheckBox() {
return root.$(Checkbox).at(0);
return root.$(Checkbox);
}

PatrolFinder getTitle() {
Expand Down Expand Up @@ -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,
Expand Down
46 changes: 42 additions & 4 deletions integration_test/scenarios/chat_scenario.dart
Original file line number Diff line number Diff line change
Expand Up @@ -488,29 +488,60 @@ class ChatScenario extends BaseScenario {
return pin.visible;
}

bool isMutedAChat(TwakeListItemRobot takeListItem) {
final muted = takeListItem.getMutedIcon();
return muted.visible;
}

Future<void> 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<void> 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<void> 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<void> 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());
}
}

Expand All @@ -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<void> 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"');
}
}
20 changes: 14 additions & 6 deletions integration_test/tests/chat/chat_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},
);
}
Loading