-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Rework testing of Find Text Feature results presentation #7355
Conversation
… occurrences and files
…orer(checkTextResultsPagination())
@@ -491,10 +494,12 @@ public void clickOnNextPageButton() { | |||
} | |||
|
|||
public Boolean checkNextPageButtonIsEnabled() { | |||
WaitUtils.sleepQuietly(1); |
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.
If possible it is better to avoid WaitUtils.sleepQuietly(1);
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.
visibilityOfElementLocated
would work well here
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.
The next and previous page buttons are always visible in the Find Text Info panel and timeout is needed for waiting that the buttons can change their status after clicking(enabled or disabled).
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 guess there is a way :)
@@ -506,4 +511,21 @@ public void openFileNodeByDoubleClick(String pathToFile) { | |||
.click(); | |||
actionsFactory.createAction(seleniumWebDriver).doubleClick().perform(); | |||
} | |||
|
|||
/** get number of found occurrences in a page */ |
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 suggest you to create data value class to encapsulate each number:
SearchFileResult(String result)
-----------------------
private final int foundOnPage;
private final int occurrenceOnPage;
private final int totalFound;
-----------------------
public int getFoundOnPage()
public int getOccurranceOnPage()
public int getTotalFound()
-----------------------
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.
This object SearchFileResult being returned from the dedicated method of FindText class allows to get all required data by one method call, and to have logic to parse the search results string in one most suitable place, that is to comply the Single Responsibility Principle.
|
||
/** get number of found occurrences in a page */ | ||
public int getFoundOccurrencesNumberOnPage() { | ||
List<String> results = new ArrayList<>(Arrays.asList(getResults().split(" "))); |
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.
We don't need to convert from array to list and back here, so as split() command returns String[].
You can use this command here instead:
return Integer.parseInt(getResults().split(" ")[0]);
// check results on second page and the previous page button is enabled | ||
Assert.assertEquals(findText.getResults(), resultsOnSecondPage); | ||
// Check move page buttons status on the second page | ||
Assert.assertTrue(findText.checkNextPageButtonIsEnabled()); |
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.
It's better to use static import here to improve readability.
return Integer.parseInt(getResults().split(" ")[0]); | ||
} | ||
public static class SearchFileResult { | ||
private int occurrencesFoundOnPage; |
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.
don't forget to make them final
sumOfFoundOccurrences += findText.getFoundOccurrencesNumberOnPage(); | ||
Assert.assertTrue(findText.checkNextPageButtonIsEnabled()); | ||
Assert.assertFalse(findText.checkPreviousPageButtonIsEnabled()); | ||
sumOfFoundFiles += findText.getResults().getFoundFilesOnPage(); |
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.
It's better to set the returning by findText.getResults()
object to the variable and then use it to get the numbers, to avoid multiple execution of commands inside the constructor SearchFileResult()
.
sumOfFoundOccurrences += findText.getFoundOccurrencesNumberOnPage(); | ||
Assert.assertTrue(findText.checkNextPageButtonIsEnabled()); | ||
Assert.assertFalse(findText.checkPreviousPageButtonIsEnabled()); | ||
sumOfFoundFiles += findText.getResults().getFoundFilesOnPage(); |
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.
What about renaming findText variable to the more suitable one like "testFinder", "findTextPage"?
ci-build |
Build success. https://ci.codenvycorp.com/job/che-pullrequests-build/4331/ |
What does this PR do?
We need rework the FindTextFeatureTest selenium test:
What issues does this PR fix or reference?
#7327