-
Notifications
You must be signed in to change notification settings - Fork 47
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
#4926: Tests refactoring: Paginator element #5386
Open
Kate-Semenova
wants to merge
13
commits into
angular_rework_development
Choose a base branch
from
angular-paginator-tests
base: angular_rework_development
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
Changes from 4 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ab7732d
#4926: Tests refactoring: Paginator element
Kate-Semenova b3370dd
#4926: Tests refactoring: Paginator element fix 1
Kate-Semenova 8b6f43f
#4926: Tests refactoring: Paginator element fix 2
Kate-Semenova 1fc5b56
#4926: Tests refactoring: Paginator element fix 3 remove hierarchy
Kate-Semenova b710d69
#4926: Tests refactoring: Paginator element
Kate-Semenova 5cf53f5
#4926: Tests refactoring: Paginator element fix 1
Kate-Semenova d01c38b
#4926: Tests refactoring: Paginator element fix 2
Kate-Semenova 211bbdf
#4926: Tests refactoring: Paginator element fix 3 remove hierarchy
Kate-Semenova 772e85c
solve conflicts
Kate-Semenova 4ccc554
Merge remote-tracking branch 'origin/angular-paginator-tests' into an…
Kate-Semenova 93aee34
#4926: Tests refactoring: Paginator element. Color refactor
Kate-Semenova be4ca55
#4926: Tests refactoring: Paginator element. PaginatorSelector.java
Kate-Semenova eee5937
#4926: Tests refactoring: Paginator element. JPaginator.java
Kate-Semenova 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 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
42 changes: 42 additions & 0 deletions
42
jdi-light-angular-tests/src/main/java/io/github/com/pages/PaginatorPage.java
This file contains 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 @@ | ||
package io.github.com.pages; | ||
|
||
import com.epam.jdi.light.angular.elements.common.Input; | ||
import com.epam.jdi.light.angular.elements.common.Tooltip; | ||
import com.epam.jdi.light.angular.elements.complex.Paginator; | ||
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; | ||
import com.epam.jdi.light.ui.html.elements.common.Text; | ||
|
||
public class PaginatorPage extends NewAngularPage { | ||
@UI("#paginator-list-length-input") | ||
public static Input listLengthInput; | ||
@UI("#paginator-page-size-input") | ||
public static Input pageSizeInput; | ||
@UI("#paginator-page-size-options-input") | ||
public static Input pageSizeOptionsInput; | ||
|
||
@UI("//paginator-configurable-example//div[contains(text(),'List length:')]") | ||
public static Text listLength; | ||
@UI("//paginator-configurable-example//div[contains(text(),'Page size:')]") | ||
public static Text pageSize; | ||
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. the same as above |
||
@UI("//paginator-configurable-example//div[contains(text(),'Page index:')]") | ||
public static Text pageIndex; | ||
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. the same as above |
||
|
||
@UI(".mat-mdc-tooltip") | ||
public static Tooltip tooltip; | ||
|
||
@UI("//paginator-configurable-example//mat-paginator") | ||
public static Paginator paginatorConfigurable; | ||
|
||
@UI("//mat-paginator[contains(@id, 'paginator-show-first-last-buttons')]") | ||
public static Paginator paginatorFirstLastButtons; | ||
@UI("#paginator-color-themepalette-primary") | ||
public static Paginator paginatorColorPrimary; | ||
@UI("#paginator-color-themepalette-accent") | ||
public static Paginator paginatorColorAccent; | ||
@UI("#paginator-color-themepalette-warn") | ||
public static Paginator paginatorColorWarn; | ||
@UI("#paginator-disabled-option") | ||
public static Paginator paginatorDisabledOption; | ||
@UI("#paginator-hide-page-size-option") | ||
public static Paginator paginatorHideSizeOption; | ||
} |
17 changes: 0 additions & 17 deletions
17
jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/PaginatorSection.java
This file was deleted.
Oops, something went wrong.
193 changes: 128 additions & 65 deletions
193
...lar-tests/src/test/java/io/github/epam/angular/tests/elements/complex/PaginatorTests.java
This file contains 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 |
---|---|---|
@@ -1,106 +1,169 @@ | ||
package io.github.epam.angular.tests.elements.complex; | ||
|
||
import io.github.epam.TestsInit; | ||
import org.openqa.selenium.Dimension; | ||
import org.testng.annotations.BeforeMethod; | ||
import org.testng.annotations.Ignore; | ||
import org.testng.annotations.BeforeClass; | ||
import org.testng.annotations.Test; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.Random; | ||
import java.util.stream.Collectors; | ||
|
||
import static com.epam.jdi.light.driver.WebDriverFactory.getDriver; | ||
import static io.github.com.StaticSite.angularPage; | ||
import static io.github.com.pages.sections.PaginatorSection.*; | ||
import static io.github.epam.site.steps.States.shouldBeLoggedIn; | ||
import static com.epam.jdi.light.angular.elements.enums.AngularColors.ACCENT; | ||
import static com.epam.jdi.light.angular.elements.enums.AngularColors.PRIMARY; | ||
import static com.epam.jdi.light.angular.elements.enums.AngularColors.WARN; | ||
import static com.jdiai.tools.Timer.waitCondition; | ||
import static io.github.com.StaticSite.paginatorPage; | ||
import static io.github.com.pages.PaginatorPage.listLengthInput; | ||
import static io.github.com.pages.PaginatorPage.pageSizeOptionsInput; | ||
import static io.github.com.pages.PaginatorPage.paginatorColorAccent; | ||
import static io.github.com.pages.PaginatorPage.paginatorColorPrimary; | ||
import static io.github.com.pages.PaginatorPage.paginatorColorWarn; | ||
import static io.github.com.pages.PaginatorPage.paginatorConfigurable; | ||
import static io.github.com.pages.PaginatorPage.paginatorDisabledOption; | ||
import static io.github.com.pages.PaginatorPage.paginatorFirstLastButtons; | ||
import static io.github.com.pages.PaginatorPage.paginatorHideSizeOption; | ||
import static java.lang.String.format; | ||
|
||
// TODO Move to the new page | ||
@Ignore | ||
public class PaginatorTests extends TestsInit { | ||
private static final List<Integer> PAGESIZEOPTIONS = Arrays.asList(1, 5, 10, 25, 100, 500); | ||
private static final List<Integer> PAGE_SIZE_OPTIONS = Arrays.asList(1, 5, 10, 25, 100, 500); | ||
private static final String OPTIONS = | ||
PAGESIZEOPTIONS | ||
PAGE_SIZE_OPTIONS | ||
.stream() | ||
.map(String::valueOf) | ||
.collect(Collectors.joining(",")); | ||
private static final int TOTAL = 50; | ||
private static final int STEP = 100; | ||
private static final int PAGE_SIZE = 10; | ||
private static final int LENGTH = STEP * PAGE_SIZE - new Random().nextInt(STEP); | ||
private static final String RANGE_PATTERN = "%d - %d / %d"; | ||
|
||
@BeforeMethod | ||
@BeforeClass | ||
public void before() { | ||
getDriver().manage().window().setSize(new Dimension(1920, 1080)); | ||
|
||
shouldBeLoggedIn(); | ||
angularPage.shouldBeOpened(); | ||
|
||
listLength.setValue(String.valueOf(TOTAL)); | ||
pageSizeOptions.setValue(OPTIONS); | ||
paginatorPage.open(); | ||
waitCondition(() -> paginatorPage.isOpened()); | ||
paginatorPage.checkOpened(); | ||
} | ||
|
||
@Test | ||
@Test(description = "The test checks item per page label") | ||
public void labelPaginationTest() { | ||
paginator.has().label("Items per page:"); | ||
paginatorConfigurable.has().pageSizeLabel("Items per page:"); | ||
} | ||
|
||
@Test | ||
@Test(description = "The test checks length and pageIndex for paginator") | ||
public void basicPaginatorTest() { | ||
final int STEP = 10; | ||
paginator.select(STEP); | ||
|
||
paginator.is().range(1, STEP, TOTAL); | ||
paginator.is().previousDisabled(); | ||
paginator.is().nextEnabled(); | ||
paginator.next(); | ||
|
||
for (int i = STEP + 1; i < TOTAL - STEP + 1; i += STEP) { | ||
paginator.is().range(i, i + STEP - 1, TOTAL); | ||
paginator.is().previousEnabled(); | ||
paginator.is().nextEnabled(); | ||
paginator.next(); | ||
waitCondition(() -> listLengthInput.isVisible()); | ||
listLengthInput.setValue(String.valueOf(LENGTH)); | ||
paginatorConfigurable.selectItemPerPageOption(STEP); | ||
//First page | ||
paginatorConfigurable.has().pageIndexCurrent(0) | ||
.and().has().totalNumberOfPaginatedItems(LENGTH) | ||
.and().has().rangeLabel(format(RANGE_PATTERN, 1, Math.min(STEP, LENGTH), LENGTH)) | ||
.and().has().nextPageButtonEnabled() | ||
.and().has().previousPageButtonDisabled(); | ||
paginatorConfigurable.nextPage(); | ||
|
||
//Go through each page sequentially: | ||
for (int pageIndex = 1; pageIndex < PAGE_SIZE - 1; pageIndex++) { | ||
final String rangeLabel = format(RANGE_PATTERN, pageIndex * STEP + 1, Math.min(pageIndex * STEP + STEP, LENGTH), LENGTH); | ||
|
||
paginatorConfigurable.has().pageIndexCurrent(pageIndex) | ||
.and().has().totalNumberOfPaginatedItems(LENGTH) | ||
.and().has().rangeLabel(rangeLabel) | ||
.and().has().nextPageButtonEnabled() | ||
.and().has().previousPageButtonEnabled(); | ||
paginatorConfigurable.nextPage(); | ||
} | ||
//Last page | ||
paginatorConfigurable.has().pageIndexCurrent(PAGE_SIZE - 1) | ||
.and().has().totalNumberOfPaginatedItems(LENGTH) | ||
.and().has().rangeLabel(format(RANGE_PATTERN, (PAGE_SIZE - 1) * STEP + 1, Math.min((PAGE_SIZE - 1) * STEP + STEP, LENGTH), LENGTH)) | ||
.and().has().previousPageButtonEnabled() | ||
.and().has().nextPageButtonDisabled(); | ||
paginatorConfigurable.previousPage(); | ||
|
||
//Go through each page backwards | ||
for (int pageIndex = PAGE_SIZE - 2; pageIndex > 0; pageIndex--) { | ||
final String rangeLabel = format(RANGE_PATTERN, pageIndex * STEP + 1, Math.min(pageIndex * STEP + STEP, LENGTH), LENGTH); | ||
|
||
paginatorConfigurable.has().pageIndexCurrent(pageIndex) | ||
.and().has().totalNumberOfPaginatedItems(LENGTH) | ||
.and().has().rangeLabel(rangeLabel) | ||
.and().has().nextPageButtonEnabled() | ||
.and().has().previousPageButtonEnabled(); | ||
paginatorConfigurable.previousPage(); | ||
} | ||
//First page | ||
paginatorConfigurable.has().pageIndexCurrent(0) | ||
.and().has().totalNumberOfPaginatedItems(LENGTH) | ||
.and().has().rangeLabel(format(RANGE_PATTERN, 1, Math.min(STEP, LENGTH), LENGTH)) | ||
.and().has().previousPageButtonDisabled() | ||
.and().has().nextPageButtonEnabled(); | ||
|
||
paginator.is().range(TOTAL - STEP + 1, TOTAL, TOTAL); | ||
paginator.is().previousEnabled(); | ||
paginator.is().nextDisabled(); | ||
paginator.previous(); | ||
} | ||
|
||
for (int i = TOTAL - 2 * STEP + 1; i > 1; i -= STEP) { | ||
paginator.is().range(i, i + STEP - 1, TOTAL); | ||
paginator.is().previousEnabled(); | ||
paginator.is().nextEnabled(); | ||
Kate-Semenova marked this conversation as resolved.
Show resolved
Hide resolved
|
||
paginator.previous(); | ||
} | ||
@Test(description = "The test checks first page and last page buttons labels for paginator") | ||
public void firstAndLastPageButtonPaginatorTest() { | ||
paginatorFirstLastButtons.has().firstLastButtonsShown(true) | ||
.and().has().firstPageLabel("test firstPageLabel") | ||
.and().has().lastPageLabel("test lastPageLabel") | ||
.and().has().firstPageButtonDisplayed(true) | ||
.and().has().lastPageButtonDisplayed(true); | ||
|
||
paginator.is().range(1, STEP, TOTAL); | ||
paginator.is().previousDisabled(); | ||
paginator.is().nextEnabled(); | ||
paginatorConfigurable.has().firstLastButtonsShown(false); | ||
} | ||
|
||
@Test | ||
@Test(description = "The test checks color theme of the paginators") | ||
public void colorPaginatorTest() { | ||
paginatorColorPrimary.has().colorTheme(PRIMARY) | ||
.and().has().borderColor(PRIMARY) | ||
.and().has().selectedOptionColor(PRIMARY); | ||
|
||
paginatorColorPrimary.has().colorTheme("primary") | ||
.and().has().borderColor("rgb(103, 58, 183)") | ||
.and().has().selectedOptionColor("rgba(103, 58, 183, 1)"); | ||
|
||
paginatorColorWarn.has().colorTheme(WARN) | ||
.and().has().borderColor(WARN) | ||
.and().has().selectedOptionColor(WARN); | ||
|
||
paginatorColorAccent.has().colorTheme(ACCENT) | ||
.and().has().borderColor(ACCENT) | ||
.and().has().selectedOptionColor(ACCENT); | ||
} | ||
|
||
@Test(description = "The test checks disabled paginator and disabled elements of the paginators") | ||
public void navigationDisabledPaginatorTest() { | ||
listLength.setValue("0"); | ||
paginatorDisabledOption.is().disabled() | ||
.and().has().previousPageButtonDisabled() | ||
.and().has().nextPageButtonDisabled() | ||
.and().has().itemPerPageSelectorDisabled(); | ||
|
||
paginator.has().range(); | ||
paginator.has().previousDisabled(); | ||
paginator.has().nextDisabled(); | ||
paginatorHideSizeOption.is().enabled(); | ||
paginatorColorWarn.is().enabled(); | ||
} | ||
|
||
listLength.setValue("100"); | ||
paginator.select(100); | ||
paginator.has().previousDisabled(); | ||
paginator.has().nextDisabled(); | ||
@Test(description = "The test checks Item per page selector is hidden/visible") | ||
public void hidePageSizePaginatorTest() { | ||
paginatorHideSizeOption.has().hiddenPageSize(true); | ||
} | ||
|
||
@Test | ||
@Test(description = "The test checks page size dropdown options") | ||
public void pageSizeOptionsPaginatorTest() { | ||
paginator.has().itemsPerPageList(PAGESIZEOPTIONS); | ||
pageSizeOptionsInput.setValue(OPTIONS); | ||
listLengthInput.focus(); | ||
paginatorConfigurable.has().itemsPerPageList(PAGE_SIZE_OPTIONS); | ||
} | ||
|
||
@Test | ||
@Test(description = "The test checks range label for page size dropdown options") | ||
public void itemPerPagePaginatorTest() { | ||
for (Integer option : PAGESIZEOPTIONS) { | ||
paginator.select(option); | ||
paginator.has().itemsPerPageSelected(option); | ||
paginator.has().range(1, Math.min(option, TOTAL), TOTAL); | ||
pageSizeOptionsInput.setValue(OPTIONS); | ||
listLengthInput.setValue(String.valueOf(LENGTH)); | ||
|
||
for (Integer option : PAGE_SIZE_OPTIONS) { | ||
paginatorConfigurable.selectItemPerPageOption(option); | ||
final String rangeLabel = format(RANGE_PATTERN, 1, Math.min(option, LENGTH), LENGTH); | ||
paginatorConfigurable.has().itemsPerPageSelected(option) | ||
.and().has().rangeLabel(rangeLabel); | ||
} | ||
} | ||
} |
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.
this is not a listLenght, it is a full message, so can be listLenghtMessage