Skip to content

Commit

Permalink
4949-refactoringCheckBoxTestsCommentsFixed
Browse files Browse the repository at this point in the history
  • Loading branch information
MayaElf committed Oct 25, 2023
1 parent 39aa934 commit 11bde65
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -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;
Expand All @@ -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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,27 @@

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;
import static io.github.com.pages.CheckBoxPage.resultCheckbox;
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()));
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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()));
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 11bde65

Please sign in to comment.