From 1184b47e2a0287e99cccd34c360a663fc63018dc Mon Sep 17 00:00:00 2001 From: Natalia Pozhidaeva Date: Mon, 15 Apr 2024 10:50:11 -0500 Subject: [PATCH] #5431 add assertions for Dialog --- .../material/tests/feedback/DialogTests.java | 2 +- .../asserts/feedback/DialogAssert.java | 27 ++++++++++++++++++- .../asserts/inputs/ButtonGroupAssert.java | 1 + .../material/elements/feedback/Dialog.java | 6 +++++ 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/feedback/DialogTests.java b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/feedback/DialogTests.java index 8557ba3b21..c356a9c40b 100644 --- a/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/feedback/DialogTests.java +++ b/jdi-light-material-ui-tests/src/test/java/io/github/epam/material/tests/feedback/DialogTests.java @@ -28,7 +28,7 @@ public void before() { @Test(enabled = false, dataProviderClass = DialogDataProvider.class, dataProvider = "simpleDialogDataProvider") public void simpleDialogTest(String titleText, int index, String text) { simpleDialogButton.click(); - simpleDialogButton.dialog().is().displayed(); + simpleDialogButton.dialog().is().displayed().and().has().title(); simpleDialogButton.dialog().title().has().text(titleText); simpleDialogButton.dialog().list().has().size(3); simpleDialogButton.dialog().list().items().get(index).has().text(text); diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/feedback/DialogAssert.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/feedback/DialogAssert.java index 2f76b7d9dc..ae624701db 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/feedback/DialogAssert.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/feedback/DialogAssert.java @@ -3,6 +3,7 @@ import com.epam.jdi.light.asserts.generic.UIAssert; import com.epam.jdi.light.common.JDIAction; import com.epam.jdi.light.material.elements.feedback.Dialog; +import org.hamcrest.Matcher; import org.hamcrest.Matchers; import static com.epam.jdi.light.asserts.core.SoftAssert.jdiAssert; @@ -10,7 +11,6 @@ /** * Assertions for {@link Dialog} */ -// @todo #5341 Assertions to add: have title, have content, have actions public class DialogAssert extends UIAssert { /** @@ -58,4 +58,29 @@ public DialogAssert displayed() { jdiAssert(element().isDisplayed(), Matchers.is(true), "Dialog is not displayed"); return this; } + + public DialogAssert title() { + jdiAssert(element().title().isExist(), Matchers.is(true), "Dialog title is not exist"); + return this; + } + + public DialogAssert title(Matcher matcher) { + jdiAssert(element().title().text(), matcher); + return this; + } + + public DialogAssert content() { + jdiAssert(element().content().isExist(), Matchers.is(true), "Dialog content is not exist"); + return this; + } + + public DialogAssert actions() { + jdiAssert(element().actionButtons().isExist(), Matchers.is(true), "Dialog actions is not exist"); + return this; + } + + public DialogAssert noActions() { + jdiAssert(element().actionButtons().isExist(), Matchers.is(false), "Dialog actions is exist"); + return this; + } } diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java index 530bc53b55..7adf593a4b 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/asserts/inputs/ButtonGroupAssert.java @@ -13,6 +13,7 @@ /** * Assertions for {@link ButtonGroup}. */ +// #todo 5431 add assertion for button text is exist public class ButtonGroupAssert extends UISelectAssert { /** diff --git a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java index 58c2c127c6..51a7520548 100644 --- a/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java +++ b/jdi-light-material-ui/src/main/java/com/epam/jdi/light/material/elements/feedback/Dialog.java @@ -2,6 +2,7 @@ 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.material.asserts.feedback.DialogAssert; import com.epam.jdi.light.material.elements.displaydata.list.SimpleList; import com.epam.jdi.light.material.elements.inputs.ButtonGroup; @@ -42,11 +43,15 @@ public Text title() { * * @return list with items within dialog as {@link SimpleList} */ + // @todo #5431 looks like list is not a required part of Dialog, should be removed @JDIAction("Get '{name}' list items") public SimpleList list() { return new SimpleList().setCore(SimpleList.class, core().find(".MuiList-root")); } + public UIElement content() { + return core().find(".MuiDialogContent-root"); + } /** * Gets the text content of this dialog. * @@ -73,6 +78,7 @@ public ButtonGroup actionButtons() { * * @return radioButtons of this dialog as {@link RadioButtons} */ + // @todo #5431 radiobuttons is not a part of standard dialog, should be removed @JDIAction("Get '{name}' radio buttons") public RadioButtons radioButtons() { return new RadioButtons().setCore(RadioButtons.class, core().find(".MuiRadio-root"));