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

#4926: Tests refactoring: Paginator element #5386

Open
wants to merge 4 commits into
base: angular_rework_development
Choose a base branch
from

Conversation

Kate-Semenova
Copy link
Contributor

Refactored tests for PaginatorTests
Added new ones to cover the following features:
firstPageLabel: string
lastPageLabel: string
color: ThemePalette
disabled: boolean
hidePageSize: boolean
length: number
pageIndex: number
showFirstLastButtons: boolean

@Kate-Semenova Kate-Semenova self-assigned this Jan 26, 2024
@Kate-Semenova Kate-Semenova linked an issue Jan 26, 2024 that may be closed by this pull request
8 tasks
@pnatashap
Copy link
Contributor

@Kate-Semenova there are style errors, as you can see from the automatic checks

@Kate-Semenova Kate-Semenova force-pushed the angular-paginator-tests branch 2 times, most recently from facaf4f to 1a7c77c Compare January 29, 2024 08:59
}

@Override
@JDIAction(value = "Is '{name}' expanded", level = DEBUG, timeout = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why we do not want to wait till it will be opened?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

copied-pasted. ill remove waiters


public PaginatorSelector() {
super();
cdkOverlayContainer.backdropSelectPanel = "div.mat-mdc-select-panel";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
cdkOverlayContainer.backdropSelectPanel = "div.mat-mdc-select-panel";
cdkOverlayContainer.backdropSelectPanelLocaltor = "div.mat-mdc-select-panel";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I chose not to add any changes to the existing com.epam.jdi.light.angular.elements.composite.MaterialSelectorContainer, especially as it is in progress within PR #5096

Copy link
Contributor

Choose a reason for hiding this comment

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

неправильная иерархия и все

return this.core();
}

@JDIAction("Get '{name}' selected value from selector")
Copy link
Contributor

Choose a reason for hiding this comment

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

Result is toogle text. On previous method it is called toggle, now it is selected value, below we can see a method "selectedElement" and it has absolutely different search logic.
All the name must be aligned and clear

Copy link
Contributor

Choose a reason for hiding this comment

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

так и не исправлено

@Override
public PaginatorAssert is() {
return new PaginatorAssert().set(this);
@JDIAction("Get COLOR for selected value in the list of options for '{name}'")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@JDIAction("Get COLOR for selected value in the list of options for '{name}'")
@JDIAction("Get color for selected value in the list of options for '{name}'")

public PaginatorAssert is() {
return new PaginatorAssert().set(this);
@JDIAction("Get COLOR for selected value in the list of options for '{name}'")
public String colorInList() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Method name is not correct: according to the code we see that color is from selected element (typically they are differ)

}

@JDIAction("Get if '{name}' has first and last page buttons shown")
public boolean showFirstLastButtons() {
Copy link
Contributor

Choose a reason for hiding this comment

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

show means an action, methods change nothing. Must be renamed

return next.isEnabled();
@JDIAction("Get COLOR theme for '{name}'")
public AngularColors color() {
final AngularColors color = AngularColors.fromName(core().attr("color"));
Copy link
Contributor

Choose a reason for hiding this comment

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

Not all colors can exists in our table, it can be customer color, we should be still able to get it

public void next() {
next.click();
@JDIAction("Get COLOR of selector`s boarder for '{name}'")
public String colorOfBoarder() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public String colorOfBoarder() {
public String borderColor() {

private static final String PAGINATOR_PAGE_SIZE_SECTION_LOCATOR = ".mat-mdc-paginator-page-size";
private static final String ITEM_PER_PAGE_SELECTOR_LOCATOR = "mat-select";
private final PaginatorSelector itemPerPageSelector;
private static final Pattern PATTERN = Pattern.compile("^(\\d+)( . (\\d+))? .+ (\\d+)");
Copy link
Contributor

Choose a reason for hiding this comment

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

Patter for what?

return this.core();
}

@JDIAction("Get '{name}' selected value from selector")
Copy link
Contributor

Choose a reason for hiding this comment

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

так и не исправлено

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

Choose a reason for hiding this comment

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

Suggested change
@BeforeMethod
@BeforeClass

public void labelPaginationTest() {
paginator.has().label("Items per page:");
paginatorConfigurable.has().itemPerPageLabel("Items per page:");
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
paginatorConfigurable.has().itemPerPageLabel("Items per page:");
paginatorConfigurable.has().pageSizeLabel("Items per page:");


@JDIAction(value = "Assert that '{name}' has '{0}' color theme", isAssert = true)
public PaginatorAssert colorTheme(final AngularColors value) {
final AngularColors color = AngularColors.fromName(element().colorTheme());
Copy link
Contributor

Choose a reason for hiding this comment

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

получение цвета должно быть в jdiAssert
и везде ниже тоже

}

@JDIAction(value = "Assert that '{name}' has page index of {0}", isAssert = true)
public PaginatorAssert totalNumberOfItems(int length) {
Copy link
Contributor

Choose a reason for hiding this comment

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

кто такие Items в этом методе?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh, sorry. Я не отредактировала документацию. Total number of items that are being paginated. Возможно, имеет смысл оставить как "length"
image

Я точно исправлю JDIAction и подумаю, как лучше назвать метод

public void previousEnabled() {
jdiAssert(element().isPreviousEnabled(), Matchers.is(true), "ERROR MESSAGE IS REQUIRED");
public PaginatorAssert previousEnabled() {
jdiAssert(element().previousButton().isEnabled() ? "enabled" : "disabled", Matchers.equalTo("enabled"));
Copy link
Contributor

Choose a reason for hiding this comment

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

не надо сравнивать строки, сравниваем boolean и пишем нормальное сообщение об ошибке

и ниже тоже

}

@JDIAction(value = "Assert that previous button enabled for '{name}'", isAssert = true)
public void previousEnabled() {
jdiAssert(element().isPreviousEnabled(), Matchers.is(true), "ERROR MESSAGE IS REQUIRED");
public PaginatorAssert previousEnabled() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
public PaginatorAssert previousEnabled() {
public PaginatorAssert previousPageButtonEnabled() {

}

@JDIAction(value = "Assert that first page button displayed={0} for '{name}'", isAssert = true)
public PaginatorAssert firstPageDisplayed(boolean value) {
Copy link
Contributor

Choose a reason for hiding this comment

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

имя метода путает: в нем написано, что проверяем, оторбражается ли первая страница, а имеется ввиду отображается ли кнопка перехода к первой странице

@Kate-Semenova Kate-Semenova force-pushed the angular-paginator-tests branch 2 times, most recently from 344222c to d55cc1d Compare February 2, 2024 13:29
Copy link
Contributor

@pnatashap pnatashap left a comment

Choose a reason for hiding this comment

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

и повторить ООП

@@ -35,8 +35,12 @@ public static AngularColors fromStyle(String styleName) {
}

public static AngularColors fromColor(String color) {
final String finalColor = color.startsWith("rgb(")
? color.replace("rgb(", "rgba(").replace(")", ", 1)")
Copy link
Contributor

Choose a reason for hiding this comment

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

rgb мы заменяем на rgba только условно, а вот в конец мы в любом случае добавляем 1, т.е. если вход будет rgba, то он станет невалидным цветом

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@pnatashap В данном случае я не до конца понимаю, что нужно менять. Отталкиваюсь в первую очередь от того, что уже есть в фреймворке, а это енам, хардкорженные значения:
image

}

@Override
@JDIAction(value = "Check that '{name}' is enabled", timeout = 0)
Copy link
Contributor

Choose a reason for hiding this comment

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

в чем необходимость добавление 0вого timeout?


@Override
@JDIAction("Expand '{name}'")
public void expand() {
Copy link
Contributor

Choose a reason for hiding this comment

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

метод путает - иногда бывает, что в paginator есть возможность увидеть номера страниц посередине, например, а тут видимо открытие выпадающего списка с размером страницы, не очевидный метод, надо переиновывать

}

@JDIAction("Get '{name}' selected UIElement from the list")
public UIElement selectedOptionFromList() {
Copy link
Contributor

Choose a reason for hiding this comment

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

а почему так непонятно Option?
мы вибираем размер страницы, вот так и должен называться метод


@Override
@JDIAction("Get 'name' toggle")
protected UIElement toggle() {
Copy link
Contributor

Choose a reason for hiding this comment

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

что за toggle? это просто этот элемент и ничего больше


public PaginatorSelector() {
super();
cdkOverlayContainer.backdropSelectPanel = "div.mat-mdc-select-panel";
Copy link
Contributor

Choose a reason for hiding this comment

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

неправильная иерархия и все


import java.util.NoSuchElementException;

public class PaginatorSelector extends MaterialSelector {
Copy link
Contributor

Choose a reason for hiding this comment

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

проблема с построением класса: этот класс не расширяет MaterialSelector, а содержит (причем опционально его, выпадающий список с размером страницы вообще может отсутствовать)
удалить наследование и излишне приписанные методы и пересмотреть все элементы и методы

public static Input pageSizeOptionsInput;

@UI("//paginator-configurable-example//div[contains(text(),'List length:')]")
public static Text listLength;
Copy link
Contributor

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

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

Choose a reason for hiding this comment

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

the same as above

@UI("//paginator-configurable-example//div[contains(text(),'Page size:')]")
public static Text pageSize;
@UI("//paginator-configurable-example//div[contains(text(),'Page index:')]")
public static Text pageIndex;
Copy link
Contributor

Choose a reason for hiding this comment

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

the same as above

private Pattern rangeLabelPattern = Pattern.compile("^(\\d+)( . (\\d+))? .+ (\\d+)");

@JDIAction("Set pattern for '{name}' range label")
public void setRangeLabelPattern(String regex) {
Copy link
Contributor

Choose a reason for hiding this comment

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

должно задаваться аннотацией и инициализироваться конструктором

range = new UIElement();
range.setLocator(rangeLocator);
@JDIAction("Get item per page selector for '{name}'")
public UIElement itemPerPageSelector() {
Copy link
Contributor

Choose a reason for hiding this comment

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

список должен быть вынесен в отдельный элемент, потому что в общей куче все эти методы по открыть, закрыть, получить список - выглядят странно

private static final String SELECT_PANEL_LOCATOR = "div.mat-mdc-select-panel";
private static final String ITEM_PER_PAGE_OPTIONS_LOCATOR = "mat-option";
private static final String ARIA_EXPANDED_ATTR = "aria-expanded";
private static final String COLOR_ATT = "color";
Copy link
Contributor

Choose a reason for hiding this comment

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

достаточно стандартный атрибут и кажется у нас есть интерфейс HasColor
не вижу необходимости вносить в константы


public class PaginatorAssert extends UIAssert<PaginatorAssert, Paginator> {
@JDIAction(value = "Assert that '{name}' has '{0}' label", isAssert = true)
public void label(String label) {
jdiAssert(element().label(), Matchers.is(label));
public PaginatorAssert pageSizeLabel(final String label) {
Copy link
Contributor

Choose a reason for hiding this comment

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

должна быть еще валидация с матчером, не только на равно

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
JDI Light Board
  
Awaiting triage
Development

Successfully merging this pull request may close these issues.

Tests refactoring: Paginator element
2 participants