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

4949-refactoringCheckBoxTests #5084

Merged
merged 15 commits into from
Nov 8, 2023
Merged
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import io.github.com.pages.BadgePage;
import io.github.com.pages.ButtonTogglePage;
import io.github.com.pages.ButtonsPage;
import io.github.com.pages.CheckBoxPage;
import io.github.com.pages.ProgressBarPage;
import io.github.com.pages.ProgressSpinnerPage;

Expand All @@ -33,4 +34,7 @@ public class StaticSite {

@Url("autocompletes")
public static AutocompletePage autocompletePage;

@Url("checkbox")
public static CheckBoxPage checkBoxPage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package io.github.com.enums;

public enum CheckBoxAlignPosition {
BEFORE("before"),
AFTER("after");
private final String alignPosition;

CheckBoxAlignPosition(String alignPosition) {
this.alignPosition = alignPosition;
}

public String getAlignPosition() {
return this.alignPosition;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ public class AngularPage extends WebPage {
public static BottomSheet bottomSheet;
public static Dialog dialog;
public static RadioButtonSection radioButtonSection;
public static CheckboxSection checkboxSection;
public static ToolbarSection toolbarSection;
public static SlideToggleSection slideToggleSection;
public static InputSection inputSection;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
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.Text;

public class CheckBoxPage extends NewAngularPage {
@UI("#basic-checkbox")
public static Checkbox basicCheckbox;

@UI("#indeterminate-checkbox")
public static Checkbox indeterminateCheckbox;

@UI("#disabled-checkbox")
public static Checkbox disabledCheckbox;

@UI("#result-checkbox")
public static Checkbox resultCheckbox;

@UI(".mat-mdc-radio-group")
public static RadioButtons modeRadioGroup;

@UI("#checkbox-color1")
public static Checkbox primaryColorCheckbox;

@UI("#checkbox-color2")
public static Checkbox accentColorCheckbox;

@UI("#checkbox-color3")
public static Checkbox warnColorCheckbox;

@UI("#checkbox-required-option")
public static Checkbox requiredCheckbox;

@UI("//*[@class='error']")
public static Text requiredCheckboxText;

}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,57 +1,104 @@
package io.github.epam.angular.tests.elements.common;

import com.epam.jdi.light.angular.elements.enums.AngularColors;
import io.github.epam.TestsInit;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Ignore;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import static io.github.com.StaticSite.angularPage;
import static io.github.com.pages.sections.CheckboxSection.*;
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
import static io.github.com.enums.CheckBoxAlignPosition.AFTER;
import static io.github.com.enums.CheckBoxAlignPosition.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.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;

// TODO Move to the new page
@Ignore
public class CheckboxTests extends TestsInit {
@BeforeMethod(alwaysRun = true)
@BeforeClass(alwaysRun = true)
public void before() {
shouldBeLoggedIn();
angularPage.open();
disabledCheckbox.show();
checkBoxPage.open();
waitCondition((() -> checkBoxPage.isOpened()));
checkBoxPage.checkOpened();
}

@Test
public void checkLabelValue() {
@Test(description = "Test verifies label value of checkbox")
public void checkLabelValueTest() {
basicCheckbox.label().has().value("Check me!");
resultCheckbox.label().has().value("I'm a checkbox");
}

@Test
public void basicCheckboxValidation() {
@Test(description = "Test verifies initial checkbox state and selection")
public void basicCheckboxValidationTest() {
basicCheckbox.show();
basicCheckbox.is().displayed().and().enabled().and().deselected();
vklonin marked this conversation as resolved.
Show resolved Hide resolved
}

@Test
public void checkBasicCheckbox() {
basicCheckbox.check();
basicCheckbox.is().selected();
vklonin marked this conversation as resolved.
Show resolved Hide resolved
basicCheckbox.uncheck();
}

@Test
public void indeterminateTest() {
indeterminateCheckbox.click();
@Test(description = "Test verifies checkbox feature: indeterminate")
public void indeterminateCheckBoxTest() {
indeterminateCheckbox.show();
indeterminateCheckbox.check();
resultCheckbox.is().indeterminate();
pnatashap marked this conversation as resolved.
Show resolved Hide resolved
indeterminateCheckbox.uncheck();
basicCheckbox.is().notIndeterminate();
}

@Test
public void disabledOption() {
disabledCheckbox.click();
@Test(description = "Test verifies checkbox disabled state")
public void disabledOptionCheckBoxTest() {
disabledCheckbox.check();
pnatashap marked this conversation as resolved.
Show resolved Hide resolved
resultCheckbox.is().disabled();
disabledCheckbox.uncheck();
resultCheckbox.is().enabled();
}

@Test
public void configurableCheckboxTest() {
indeterminateCheckbox.check();
alignBeforeRadioButton.click();
resultCheckbox.is().indeterminate().and().cssClass("mat-checkbox-label-before");
pnatashap marked this conversation as resolved.
Show resolved Hide resolved
@Test(description = "Test verifies checkbox align positions")
public void alignPositionsCheckboxTest() {
modeRadioGroup.click(BEFORE.getAlignPosition());
resultCheckbox.is().alignedBefore();
modeRadioGroup.click(AFTER.getAlignPosition());
resultCheckbox.is().alignedAfter();
}

@Test(description = "Test verifies checkbox feature: required option")
public void isRequiredCheckboxTest() {
requiredCheckbox.show();
requiredCheckbox.is().required();
requiredCheckboxText.has().text("Checkbox should be checked!");
requiredCheckbox.check();
requiredCheckboxText.is().notVisible();
requiredCheckbox.uncheck();
basicCheckbox.is().notRequired();
warnColorCheckbox.is().notRequired();
}

@Test(description = "Verifies checkbox colors as Angular colors")
public void angularColorCheckBoxTest() {
//Check color for checkboxes with attribute 'color'
primaryColorCheckbox.has().angularColor(AngularColors.PRIMARY);
accentColorCheckbox.has().angularColor(AngularColors.ACCENT);
warnColorCheckbox.has().angularColor(AngularColors.WARN);
//Check color for checkbox without attribute 'color'
requiredCheckbox.has().angularColor(AngularColors.ACCENT);
}

@Test(description = "Verifies checkbox colors as strings")
public void colorCheckBoxTest() {
//Check color for checkboxes with attribute 'color'
primaryColorCheckbox.has().color("primary");
accentColorCheckbox.has().color("accent");
warnColorCheckbox.has().color("warn");
//Check color for checkbox without attribute 'color'
requiredCheckbox.has().color("accent");
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.epam.jdi.light.angular.asserts;

import com.epam.jdi.light.angular.elements.common.Checkbox;
import com.epam.jdi.light.angular.elements.enums.AngularColors;
import com.epam.jdi.light.asserts.generic.UIAssert;
import com.epam.jdi.light.common.JDIAction;
import org.hamcrest.Matchers;
Expand All @@ -10,33 +11,76 @@
public class CheckboxAssert extends UIAssert<CheckboxAssert, Checkbox> {
@JDIAction("Assert that '{name}' is selected")
public CheckboxAssert selected() {
jdiAssert(element().isSelected(), Matchers.is(true));
jdiAssert(element().isSelected(), Matchers.is(true), "Checkbox is not selected");
return this;
}

@JDIAction("Assert that '{name}' is not selected")
public CheckboxAssert deselected() {
jdiAssert(element().isSelected(), Matchers.is(false));
jdiAssert(element().isSelected(), Matchers.is(false), "Checkbox is selected");
return this;
}

@JDIAction("Assert that '{name}' is indeterminate")
public CheckboxAssert indeterminate() {
jdiAssert(element().isIndeterminate(), Matchers.is(true));
jdiAssert(element().isIndeterminate(), Matchers.is(true), "Checkbox is determinate");
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() {
jdiAssert(element().isEnabled(), Matchers.is(true));
jdiAssert(element().isEnabled(), Matchers.is(true), "Checkbox is disabled");
return this;
}

@JDIAction("Assert that '{name}' is disabled")
@Override
public CheckboxAssert disabled() {
jdiAssert(element().isDisabled(), Matchers.is(true));
jdiAssert(element().isDisabled(), Matchers.is(true), "Checkbox is enabled");
return this;
}

@JDIAction("Assert that '{name}' is aligned in before position")
public CheckboxAssert alignedBefore() {
jdiAssert(element().isAlignedBefore(), Matchers.is(true), "Checkbox is aligned after");
return this;
}

@JDIAction("Assert that '{name}' is aligned in after position")
public CheckboxAssert alignedAfter() {
jdiAssert(element().isAlignedBefore(), Matchers.is(false), "Checkbox is aligned before");
return this;
}

@JDIAction("Assert that '{name}' is required")
public CheckboxAssert required() {
jdiAssert(element().isRequired(), Matchers.is(true), "Checkbox does not have feature: required");
return this;
}

@JDIAction("Assert that '{name}' is not required")
public CheckboxAssert notRequired() {
jdiAssert(element().isRequired(), Matchers.is(false), "Checkbox has feature: required");
return this;
}

@JDIAction("Assert that '{name}' angular color is '{0}'")
public CheckboxAssert angularColor(AngularColors expectedColor) {
jdiAssert(element().color(), Matchers.is(expectedColor));
return this;
}

@JDIAction("Assert that '{name}' color is '{0}'")
public CheckboxAssert color(String expectedColor) {
vklonin marked this conversation as resolved.
Show resolved Hide resolved
jdiAssert(element().color().getColor(), Matchers.is(expectedColor));
return this;
}

}
Loading