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

5378 Fix failing tests for Snackbar #5379

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

Conversation

igor-korost
Copy link

No description provided.

@igor-korost igor-korost self-assigned this Jan 26, 2024
@igor-korost igor-korost changed the title 5378: Fix failing tests for Snackbar 5378 Fix failing tests for Snackbar Jan 26, 2024
snackbarSection.durationInput.setValue(String.valueOf(DURATION));
snackbarSection.customSnackbarOpenButton.click();
snackBarPage.durationInput.setValue(String.valueOf(DURATION));
snackBarPage.customSnackbarOpenButton.click();

//duration(DURATION, 1000, action);
Copy link
Contributor

Choose a reason for hiding this comment

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

удалить

Copy link
Author

Choose a reason for hiding this comment

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

Сделано

@@ -11,7 +11,7 @@

public class Snackbar extends UIBaseElement<SnackbarAssert> {
protected UIElement message;
protected String messageLocator = "./span";
protected String messageLocator = "//*[@matsnackbarlabel]";

protected UIElement action;
Copy link
Contributor

Choose a reason for hiding this comment

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

это кнопка, а не UIElement

Copy link
Author

Choose a reason for hiding this comment

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

Заменил protected UIElement action на public Button action;
Модификатор доступа изменил на public так как action после правок используется в SnackbarTests

@@ -26,7 +26,7 @@ public Snackbar() {

@JDIAction("Get '{name}' message")
public String getMessageText() {
return message.getValue();
return message.getText();
}

@JDIAction("Get '{name}' action")
Copy link
Contributor

Choose a reason for hiding this comment

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

и ниже все методы тоже требуют переименования

Copy link
Author

Choose a reason for hiding this comment

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

Переименовал getMessageText() в messageText() и getActionText() в actionText()


snackbarSection.basicSnackbar.has().action();
snackBarPage.basicSnackbar.has().action();
Copy link
Contributor

Choose a reason for hiding this comment

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

тест про NO ACTION TEST
но в валидации проверяем, что action есть - не логично

Copy link
Author

Choose a reason for hiding this comment

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

Переименовал. Теперь эта строчка выглядит так snackBarPage.basicSnackbar.has().noAction();

@pnatashap pnatashap linked an issue Jan 26, 2024 that may be closed by this pull request
3 tasks
igor-korost and others added 3 commits January 31, 2024 19:47
…ments/complex/Snackbar.java

Co-authored-by: Natalia Pozhidaeva <[email protected]>
…ests/elements/complex/SnackbarTests.java

Co-authored-by: Natalia Pozhidaeva <[email protected]>
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.

ревью компонента еще раз нужно сделать

protected UIElement action;
protected String actionLocator = ".//button";
public Button action;
protected String actionLocator = "//button";
Copy link
Contributor

Choose a reason for hiding this comment

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

а было правильно

Copy link
Author

Choose a reason for hiding this comment

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

Вернул назад


/**
* To see an example of Snackbar web element please visit https://material.angular.io/components/snack-bar/overview.
*/

public class Snackbar extends UIBaseElement<SnackbarAssert> {
protected UIElement message;
protected String messageLocator = "./span";
protected String messageLocator = "//*[@matsnackbarlabel]";
Copy link
Contributor

Choose a reason for hiding this comment

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

стиль mdc-snackbar__label гораздо более понятнее смотрится

Copy link
Author

Choose a reason for hiding this comment

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

Пофиксил. Теперь так protected String messageLocator = ".mdc-snackbar__label";

protected UIElement action;
protected String actionLocator = ".//button";
public Button action;
protected String actionLocator = "//button";

public Snackbar() {
message = new UIElement();
Copy link
Contributor

Choose a reason for hiding this comment

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

А зачем нам эти элементы хранить?

Copy link
Author

Choose a reason for hiding this comment

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

После введения проверок из элемента Button кнопка action теперь используется в тестах (сейчас кнопка переименована в actionButton). Если я правильно понял вопрос.

Copy link
Contributor

Choose a reason for hiding this comment

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

вопрос был зачем это делать в конструкторе, а не так же, как это сделано в остальных элементах

}

@JDIAction("Get '{name}' action")
public String getActionText() {
public String actionText() {
Copy link
Contributor

Choose a reason for hiding this comment

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

на самом деле при наличии доступа к кнопки мы можем на ней и проверить, что с ней, на кнопке есть свои валидаторы

Copy link
Author

Choose a reason for hiding this comment

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

Выполнено. Теперь во всех тестах SnackbarTests используются валидаторы из Button

@pnatashap
Copy link
Contributor

@igor-korost если работа закончена, то надо перезапрашивать ревью, мысли еще никто читать не научился

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.

а почему PR называется исправление падающих тестов?

protected UIElement action;
protected String actionLocator = ".//button";
public Button action;
protected String actionLocator = "//button";

public Snackbar() {
message = new UIElement();
Copy link
Contributor

Choose a reason for hiding this comment

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

вопрос был зачем это делать в конструкторе, а не так же, как это сделано в остальных элементах

protected String actionLocator = ".//button";

public Snackbar() {
message = new UIElement();
message.core().setLocator(messageLocator);

action = new UIElement();
action.core().setLocator(actionLocator);
actionButton = new Button();
Copy link
Contributor

Choose a reason for hiding this comment

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

кнопок технически можно сделать несколько, надо предусмотреть возможность с ними работать

Copy link
Author

Choose a reason for hiding this comment

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

У элементов snackbar при нормальном проектировании может быть только 1 кнопка или не быть её вообще. Так как это исчезающий элемент и можно не успеть отреагировать. 💁 Вот тут подробнее написано https://stackoverflow.com/questions/67642607/reactmaterial-ui-multiple-snackbar

Copy link
Author

Choose a reason for hiding this comment

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

Конструктор убрал из Snackbar.java

@@ -4,44 +4,30 @@
import com.epam.jdi.light.common.JDIAction;
import com.epam.jdi.light.elements.base.UIBaseElement;
import com.epam.jdi.light.elements.common.UIElement;
import com.epam.jdi.light.ui.html.elements.common.Button;

/**
* To see an example of Snackbar web element please visit https://material.angular.io/components/snack-bar/overview.
*/

public class Snackbar extends UIBaseElement<SnackbarAssert> {
protected UIElement message;
Copy link
Contributor

Choose a reason for hiding this comment

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

если message это элемент с текстом, то это должен быть не UIElement

Copy link
Author

Choose a reason for hiding this comment

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

Заменил на public String messageText(), конструктор убрал вообще

@@ -11,19 +11,7 @@ public class SnackbarAssert extends UIAssert<SnackbarAssert, Snackbar> {

@JDIAction(value = "Assert that '{name}' has message '{0}'", isAssert = true)
public SnackbarAssert message(String expected) {
Copy link
Contributor

Choose a reason for hiding this comment

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

на текст всегда ставим валидатор с матчером, чтобы не только на полное соответствие можно было проверить

Copy link
Author

Choose a reason for hiding this comment

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

Заменил на Matchers.containsString(expected)

@igor-korost
Copy link
Author

а почему PR называется исправление падающих тестов?

Название не вполне верное. Скорее это рефакторинг и исправление. Цель этого PR сдать уже сделанную работу поскольку я ухожу с проекта.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tests refactoring: fix Snackbar element tests
3 participants