-
Notifications
You must be signed in to change notification settings - Fork 38
Search msg in a chat #2651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
thuyenh1081
wants to merge
9
commits into
main
Choose a base branch
from
searchMsgInAChat
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Search msg in a chat #2651
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
bf4ea4b
remove Future when get list of chat group
thuyenh1081 124cfef
add ChatSearchViewRobot
thuyenh1081 6855bfa
add ChatDetailScenario
thuyenh1081 1bc62bd
add script Search for messages inside a chat
thuyenh1081 d8a0f0e
remove await when call getListOfChatGroup()
thuyenh1081 e4ff25c
change the way to get back button
thuyenh1081 9adeff6
fix the typo
thuyenh1081 21ae5fb
remove unused code
thuyenh1081 417de85
update case that returing empty result
thuyenh1081 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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; | ||
|
|
@@ -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 | ||
|
|
@@ -179,4 +181,27 @@ void main() { | |
|
|
||
| }, | ||
| ); | ||
|
|
||
| TestBase().runPatrolTest( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); | ||
| }, | ||
Insalien marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.$).waitForEitherVisible($ : $, first: $ (TwakeListItem), second: $("No Results"), timeout: const Duration(seconds: 10));
In this method, the result can contain one, more, or even zero items.
The code: await ChatGroupDetailRobot(
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.
There was a problem hiding this comment.
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