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
4 changes: 2 additions & 2 deletions integration_test/robots/chat_list_robot.dart
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ class ChatListRobot extends HomeRobot {
}

Future<ChatGroupDetailRobot> openChatGroupByIndex(int index) async {
await (await getListOfChatGroup())[index].root.tap();
await (getListOfChatGroup()[index].root).tap();
await $.pumpAndSettle();
return ChatGroupDetailRobot($);
}

Future<List<TwakeListItemRobot>> getListOfChatGroup() async {
List<TwakeListItemRobot> getListOfChatGroup() {
final List<TwakeListItemRobot> groupList = [];

// Evaluate once to find how many TwakeListItem widgets exist
Expand Down
42 changes: 42 additions & 0 deletions integration_test/robots/chat_search_view_robot.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import 'package:fluffychat/pages/chat_search/chat_search_view.dart';
import 'package:fluffychat/widgets/twake_components/twake_icon_button.dart';
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:linagora_design_flutter/list_item/twake_list_item.dart';
import 'package:patrol/patrol.dart';
import '../base/core_robot.dart';
import 'twake_list_item_robot.dart';

class ChatSearchViewRobot extends CoreRobot {
ChatSearchViewRobot(super.$);

PatrolFinder getBackIcon() {
const icon = IconData(0xEF4D, fontFamily: 'MaterialIcons');
return $(TwakeIconButton).containing(find.byIcon(icon));
}

PatrolFinder getTextField() {
return $(ChatSearchView).$(AppBar).$(TextField);
}

PatrolFinder getSearchIcon() {
return getTextField().$(Icon).at(0);
}

PatrolFinder getCloseIcon() {
return getTextField().$(IconButton);
}

Future<List<TwakeListItemRobot>> getListOfChatSearch() async {
final List<TwakeListItemRobot> groupList = [];

// Evaluate once to find how many TwakeListItem widgets exist
final matches = $(TwakeListItem).evaluate();
for (final element in matches) {
final finder = $(element.widget.runtimeType);
groupList.add(TwakeListItemRobot($, finder));
}
return groupList;
}

}
17 changes: 17 additions & 0 deletions integration_test/scenarios/chat_detail_scenario.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:linagora_design_flutter/list_item/twake_list_item.dart';
import '../base/base_scenario.dart';
import '../robots/chat_group_detail_robot.dart';
import 'package:flutter/material.dart';

class ChatDetailScenario extends BaseScenario {
ChatDetailScenario(super.$);

Future<void> makeASearch(String searchText) async {
await ChatGroupDetailRobot($).getSearchIcon().tap();
await $.waitUntilVisible($(AppBar).$(TextField));
await $(AppBar).$(TextField).enterText(searchText);
await ChatGroupDetailRobot($).waitForEitherVisible($: $, first: $(TwakeListItem), second: $("No Results"), timeout: const Duration(seconds: 10));
await Future.delayed(const Duration(seconds: 2));
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we at least have another search with at least one result, please?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not clear about your idea.
In this method, the result can contain one, more, or even zero items.
The code: await ChatGroupDetailRobot($).waitForEitherVisible($: $, first: $(TwakeListItem), second: $("No Results"), timeout: const Duration(seconds: 10));
means that before performing the next action after entering a search, we will wait until we either see the label “No Results” or at least one item displayed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a step with search input bar, you wait until no result show, then you will make a search? Am I right? If I am right, the method name so confused

}
6 changes: 3 additions & 3 deletions integration_test/scenarios/chat_scenario.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class ChatScenario extends BaseScenario {

Future<ChatGroupDetailRobot> openChatGroupByTitle(String groupTitle) async {
await enterSearchText(groupTitle);
await (await ChatListRobot($).getListOfChatGroup())[0].root.tap();
await (ChatListRobot($).getListOfChatGroup())[0].root.tap();
await $.pumpAndSettle();
return ChatGroupDetailRobot($);
}
Expand Down Expand Up @@ -390,7 +390,7 @@ class ChatScenario extends BaseScenario {
}

Future<void> verifySearchResultContains(String keyword) async {
final items = await ChatListRobot($).getListOfChatGroup();
final items = ChatListRobot($).getListOfChatGroup();
final length = items.length;
var i = 0;

Expand All @@ -416,7 +416,7 @@ class ChatScenario extends BaseScenario {

Future<ChatGroupDetailRobot> openChatGroup(String title) async {
await enterSearchText(title);
await (await ChatListRobot($).getListOfChatGroup())[0].root.tap();
await (ChatListRobot($).getListOfChatGroup()[0].root).tap();
final chatGroupDetailRobot = ChatGroupDetailRobot($);
await chatGroupDetailRobot.confimrAccessMedia();
await $.pumpAndSettle();
Expand Down
33 changes: 29 additions & 4 deletions integration_test/tests/chat/chat_group_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,17 @@ import 'package:flutter_test/flutter_test.dart';
import '../../base/test_base.dart';
import '../../help/soft_assertion_helper.dart';
import '../../robots/chat_group_detail_robot.dart';
import '../../robots/chat_search_view_robot.dart';
import '../../scenarios/chat_detail_scenario.dart';
import '../../scenarios/chat_scenario.dart';
import '../../robots/home_robot.dart';
import 'package:patrol/patrol.dart';

// --- Common config ---
const defaultTime = Duration(seconds: 60);
const searchPhrase =
String.fromEnvironment('SearchByTitle', defaultValue: 'My Default Group');
const forwardReceiver =
const groupTest =
String.fromEnvironment('TitleOfGroupTest', defaultValue: 'My Default Group');
const receiver =
String.fromEnvironment('Receiver', defaultValue: 'Receiver Group');

int uniqueId() => DateTime.now().microsecondsSinceEpoch;
Expand All @@ -25,7 +27,7 @@ Future<(String, String)> prepareTwoMessages(PatrolIntegrationTester $) async {
final receiverMsg = 'receiver sent at $id';

await HomeRobot($).gotoChatListScreen();
await ChatScenario($).openChatGroupByTitle(searchPhrase);
await ChatScenario($).openChatGroupByTitle(groupTest);

await ChatScenario($)
.sendAMesage(senderMsg); // NOTE: keep current helper name
Expand Down Expand Up @@ -179,4 +181,27 @@ void main() {

},
);

TestBase().runPatrolTest(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I want to run this test only, how can I do that?

description: 'Search for messages inside a chat',
test: ($) async {
final s = SoftAssertHelper();
//open chat and make some messages
final receiveMessage = (await prepareTwoMessages($)).$2;
final searchPhrase = receiveMessage.substring(receiveMessage.indexOf("sent"), receiveMessage.length);

//search by the word that contained in the text that by sent by both sender and receiver
await ChatDetailScenario($).makeASearch(searchPhrase);
// verify info dialog is shown the search phrase is displayed in the 2 messages
var numberOfResult = (await ChatSearchViewRobot($).getListOfChatSearch()).length;
s.softAssertEquals(numberOfResult == 2, true, "expect is 2 but got: $numberOfResult");

//search by the word that not existed in the chat
await ChatDetailScenario($).makeASearch("$searchPhrase no existed");
//verify there is no result
numberOfResult = (await ChatSearchViewRobot($).getListOfChatSearch()).length;
s.softAssertEquals(numberOfResult, 0, "Expected empty result, but got $numberOfResult");
s.verifyAll();
},
);
}
10 changes: 5 additions & 5 deletions integration_test/tests/chat/chat_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,24 @@ void main() {
await ChatScenario($).verifySearchResultViewIsShown();
await ChatScenario($).verifySearchResultContains(currentAccount.substring(1,3));
//return a list of result
s.softAssertEquals((await ChatListRobot($).getListOfChatGroup()).isNotEmpty, true, 'Searchby $currentAccount.substring(1,3) Expected at least 1 group, but found 0',);
s.softAssertEquals(ChatListRobot($).getListOfChatGroup().isNotEmpty, true, 'Searchby $currentAccount.substring(1,3) Expected at least 1 group, but found 0',);

// search by full an address matrix
await ChatScenario($).enterSearchText(searchByMatrixAddress);
//verify there is one result
s.softAssertEquals((await ChatListRobot($).getListOfChatGroup()).length == 1, true, 'Search by $searchByMatrixAddress Expected number of group is 1 , but found != 1');
s.softAssertEquals(ChatListRobot($).getListOfChatGroup().length == 1, true, 'Search by $searchByMatrixAddress Expected number of group is 1 , but found != 1');

// search by full an address matrix but make it in case-sensitive format
await ChatScenario($).enterSearchText(searchByMatrixAddress.toUpperCase());
//verify there is one result
s.softAssertEquals((await ChatListRobot($).getListOfChatGroup()).length == 1, true, 'Searhc by $searchByMatrixAddress.toUpperCase() Expected number of group is 1 , but found != 1');
s.softAssertEquals(ChatListRobot($).getListOfChatGroup().length == 1, true, 'Searhc by $searchByMatrixAddress.toUpperCase() Expected number of group is 1 , but found != 1');

// search by current account
await ChatScenario($).enterSearchText(currentAccount);
//verify items displayed on the TwakeListItem
//todo: handle the case list both contact and Message
s.softAssertEquals((await (await ChatListRobot($).getListOfChatGroup())[0].getOwnerLabel()).visible, true, 'Owner is missing!',);
s.softAssertEquals((await (await ChatListRobot($).getListOfChatGroup())[0].getEmailLabelIncaseSearching()).visible, true, 'Email field is not shown',);
s.softAssertEquals((await (ChatListRobot($).getListOfChatGroup()[0]).getOwnerLabel()).visible, true, 'Owner is missing!',);
s.softAssertEquals((await (ChatListRobot($).getListOfChatGroup()[0]).getEmailLabelIncaseSearching()).visible, true, 'Email field is not shown',);

// after searching, open a chat by clicking on a result
final chatGroupDetailRobot = await ChatScenario($).openChatGroup(searchByTitle);
Expand Down
Loading