From 11bde65306210ff678dfda6d101ae1c313256a36 Mon Sep 17 00:00:00 2001 From: Maya Afanaseva Date: Wed, 25 Oct 2023 16:43:14 +0300 Subject: [PATCH] 4949-refactoringCheckBoxTestsCommentsFixed --- .../io/github/com/pages/CheckBoxPage.java | 18 +++---------- .../tests/elements/common/CheckboxTests.java | 26 ++++++++++++------- .../light/angular/asserts/CheckboxAssert.java | 12 +++++++++ .../angular/elements/enums/CheckBoxModes.java | 15 +++++++++++ 4 files changed, 46 insertions(+), 25 deletions(-) create mode 100644 jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CheckBoxModes.java diff --git a/jdi-light-angular-tests/src/main/java/io/github/com/pages/CheckBoxPage.java b/jdi-light-angular-tests/src/main/java/io/github/com/pages/CheckBoxPage.java index 5a61a62711..02b3bfc500 100644 --- a/jdi-light-angular-tests/src/main/java/io/github/com/pages/CheckBoxPage.java +++ b/jdi-light-angular-tests/src/main/java/io/github/com/pages/CheckBoxPage.java @@ -1,17 +1,14 @@ package io.github.com.pages; import com.epam.jdi.light.angular.elements.common.Checkbox; +import com.epam.jdi.light.angular.elements.complex.RadioButtons; import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI; -import com.epam.jdi.light.ui.html.elements.common.Button; import com.epam.jdi.light.ui.html.elements.common.Text; public class CheckBoxPage extends NewAngularPage { @UI("#basic-checkbox") public static Checkbox basicCheckbox; - @UI("#checked-checkbox") - static Checkbox checkedCheckbox; - @UI("#indeterminate-checkbox") public static Checkbox indeterminateCheckbox; @@ -21,14 +18,8 @@ public class CheckBoxPage extends NewAngularPage { @UI("#result-checkbox") public static Checkbox resultCheckbox; - @UI("#align-before-radio-button") - public static Button alignBeforeRadioButton; - - @UI("#align-after-radio-button") - public static Button alignAfterRadioButton; - - @UI("#checkbox-aria-label") - public static Checkbox ariaLabelCheckbox; + @UI(".mat-mdc-radio-group") + public static RadioButtons modeRadioGroup; @UI("#checkbox-color1") public static Checkbox primaryColorCheckbox; @@ -39,9 +30,6 @@ public class CheckBoxPage extends NewAngularPage { @UI("#checkbox-color3") public static Checkbox warnColorCheckbox; - @UI("#checkbox-disable-ripple") - public static Checkbox disableRippleCheckbox; - @UI("#checkbox-required-option") public static Checkbox requiredCheckbox; diff --git a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java index 5c23ea457f..73cf84ab03 100644 --- a/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java +++ b/jdi-light-angular-tests/src/test/java/io/github/epam/angular/tests/elements/common/CheckboxTests.java @@ -2,18 +2,19 @@ import com.epam.jdi.light.angular.elements.enums.AngularColors; import io.github.epam.TestsInit; -import org.testng.annotations.BeforeMethod; +import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; +import static com.epam.jdi.light.angular.elements.enums.CheckBoxModes.AFTER; +import static com.epam.jdi.light.angular.elements.enums.CheckBoxModes.BEFORE; import static com.jdiai.tools.Timer.waitCondition; import static io.github.com.StaticSite.checkBoxPage; import static io.github.com.pages.CheckBoxPage.accentColorCheckbox; -import static io.github.com.pages.CheckBoxPage.alignAfterRadioButton; -import static io.github.com.pages.CheckBoxPage.alignBeforeRadioButton; import static io.github.com.pages.CheckBoxPage.basicCheckbox; import static io.github.com.pages.CheckBoxPage.disabledCheckbox; import static io.github.com.pages.CheckBoxPage.indeterminateCheckbox; +import static io.github.com.pages.CheckBoxPage.modeRadioGroup; import static io.github.com.pages.CheckBoxPage.primaryColorCheckbox; import static io.github.com.pages.CheckBoxPage.requiredCheckbox; import static io.github.com.pages.CheckBoxPage.requiredCheckboxText; @@ -21,7 +22,7 @@ import static io.github.com.pages.CheckBoxPage.warnColorCheckbox; public class CheckboxTests extends TestsInit { - @BeforeMethod(alwaysRun = true) + @BeforeClass(alwaysRun = true) public void before() { checkBoxPage.open(); waitCondition((() -> checkBoxPage.isOpened())); @@ -47,33 +48,38 @@ public void checkBasicCheckbox() { } @Test(description = "Test verifies checkbox feature: indeterminate") - public void indeterminateTest() { + public void indeterminateCheckBoxTest() { indeterminateCheckbox.show(); indeterminateCheckbox.check(); resultCheckbox.is().indeterminate(); + indeterminateCheckbox.uncheck(); + resultCheckbox.is().notIndeterminate(); } @Test(description = "Test verifies checkbox disabled state") - public void disabledOption() { + public void disabledOptionCheckBoxTest() { disabledCheckbox.check(); resultCheckbox.is().disabled(); + disabledCheckbox.uncheck(); + resultCheckbox.is().enabled(); } @Test(description = "Test verifies checkbox align positions") - public void configurableCheckboxTest() { - alignBeforeRadioButton.click(); + public void alignPositionsCheckboxTest() { + modeRadioGroup.click(BEFORE.getMode()); resultCheckbox.is().alignedBefore(); - alignAfterRadioButton.click(); + modeRadioGroup.click(AFTER.getMode()); resultCheckbox.is().alignedAfter(); } @Test(description = "Test verifies checkbox feature: required option") - public void isRequired() { + public void isRequiredCheckboxTest() { requiredCheckbox.show(); requiredCheckbox.is().isRequired(); requiredCheckboxText.has().text("Checkbox should be checked!"); requiredCheckbox.check(); requiredCheckboxText.is().notVisible(); + resultCheckbox.is().isNotRequired(); } @Test(description = "Verifies checkbox colors") diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java index 62638998be..6e61e8bc56 100644 --- a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/asserts/CheckboxAssert.java @@ -26,6 +26,12 @@ public CheckboxAssert indeterminate() { return this; } + @JDIAction("Assert that '{name}' is not indeterminate") + public CheckboxAssert notIndeterminate() { + jdiAssert(element().isIndeterminate(), Matchers.is(false), "Checkbox is indeterminate"); + return this; + } + @JDIAction("Assert that '{name}' is enabled") @Override public CheckboxAssert enabled() { @@ -58,6 +64,12 @@ public CheckboxAssert isRequired() { return this; } + @JDIAction("Assert that '{name}' is not required") + public CheckboxAssert isNotRequired() { + jdiAssert(element().isRequired(), Matchers.is(false), "Checkbox has feature: required"); + return this; + } + @JDIAction("Assert that '{name}' color is '{0}'") public CheckboxAssert color(String expectedColor) { jdiAssert(element().color().getColor(), Matchers.equalToIgnoringCase(expectedColor.toLowerCase())); diff --git a/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CheckBoxModes.java b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CheckBoxModes.java new file mode 100644 index 0000000000..59f38249c1 --- /dev/null +++ b/jdi-light-angular/src/main/java/com/epam/jdi/light/angular/elements/enums/CheckBoxModes.java @@ -0,0 +1,15 @@ +package com.epam.jdi.light.angular.elements.enums; + +public enum CheckBoxModes { + BEFORE("before"), + AFTER("after"); + private final String mode; + + CheckBoxModes(String mode) { + this.mode = mode; + } + + public String getMode() { + return this.mode; + } +}