Skip to content
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

Merged
merged 10 commits into from
Nov 17, 2017

Conversation

SkorikSergey
Copy link
Contributor

What does this PR do?

We need rework the FindTextFeatureTest selenium test:

What issues does this PR fix or reference?

#7327

@SkorikSergey SkorikSergey added kind/task Internal things, technical debt, and to-do tasks to be performed. status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. team/production labels Nov 14, 2017
@@ -491,10 +494,12 @@ public void clickOnNextPageButton() {
}

public Boolean checkNextPageButtonIsEnabled() {
WaitUtils.sleepQuietly(1);
Copy link
Contributor

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);

Copy link
Contributor

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

Copy link
Contributor Author

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).

Copy link
Contributor

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 */
Copy link
Contributor

@dmytro-ndp dmytro-ndp Nov 14, 2017

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()
-----------------------

Copy link
Contributor

@dmytro-ndp dmytro-ndp Nov 15, 2017

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(" ")));
Copy link
Contributor

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());
Copy link
Contributor

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;
Copy link
Contributor

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();
Copy link
Contributor

@dmytro-ndp dmytro-ndp Nov 16, 2017

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();
Copy link
Contributor

@dmytro-ndp dmytro-ndp Nov 16, 2017

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"?

@dmytro-ndp
Copy link
Contributor

ci-build

@codenvy-ci
Copy link

@SkorikSergey SkorikSergey merged commit 940e848 into master Nov 17, 2017
@SkorikSergey SkorikSergey deleted the reworkFindTextFeatureTest branch November 17, 2017 13:47
@benoitf benoitf removed the status/code-review This issue has a pull request posted for it and is awaiting code review completion by the community. label Nov 17, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/task Internal things, technical debt, and to-do tasks to be performed.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants