Skip to content

Commit 65f0bea

Browse files
authored
4949-refactoringCheckBoxTests (#5084)
* 4949-refactoringCheckBoxTests * 4949-refactoringCheckBoxRequiredPlus * 4949-refactoringCheckBoxRequiredPlusFix * 4949-refactoringCheckBoxCommentsFix * 4949-refactoringCheckBoxCommentsFix2 * 4949-refactoringCheckboxTestsControl1st * 4949-refactoringCheckboxTestsColorFix * 4949-refactoringCheckboxTestsCheckStyleFix * 4949-refactoringCheckBoxTestsCommentsFixed * 4949-refactoringCheckBoxTestsEnumFixed * 4949-refactoringCheckBoxEnumMoved * 4949-refCheckboxComFix * 4949-refCheckboxAngularColorFix * 4949-refCheckboxColorFix * 4949-refRadioButtonsCommentsFixed2
1 parent 2994534 commit 65f0bea

File tree

8 files changed

+229
-69
lines changed

8 files changed

+229
-69
lines changed

jdi-light-angular-tests/src/main/java/io/github/com/StaticSite.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.github.com.pages.BadgePage;
88
import io.github.com.pages.ButtonTogglePage;
99
import io.github.com.pages.ButtonsPage;
10+
import io.github.com.pages.CheckBoxPage;
1011
import io.github.com.pages.ProgressBarPage;
1112
import io.github.com.pages.ProgressSpinnerPage;
1213

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

3435
@Url("autocompletes")
3536
public static AutocompletePage autocompletePage;
37+
38+
@Url("checkbox")
39+
public static CheckBoxPage checkBoxPage;
3640
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package io.github.com.enums;
2+
3+
public enum CheckBoxAlignPosition {
4+
BEFORE("before"),
5+
AFTER("after");
6+
private final String alignPosition;
7+
8+
CheckBoxAlignPosition(String alignPosition) {
9+
this.alignPosition = alignPosition;
10+
}
11+
12+
public String getAlignPosition() {
13+
return this.alignPosition;
14+
}
15+
}

jdi-light-angular-tests/src/main/java/io/github/com/pages/AngularPage.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ public class AngularPage extends WebPage {
1717
public static BottomSheet bottomSheet;
1818
public static Dialog dialog;
1919
public static RadioButtonSection radioButtonSection;
20-
public static CheckboxSection checkboxSection;
2120
public static ToolbarSection toolbarSection;
2221
public static SlideToggleSection slideToggleSection;
2322
public static InputSection inputSection;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package io.github.com.pages;
2+
3+
import com.epam.jdi.light.angular.elements.common.Checkbox;
4+
import com.epam.jdi.light.angular.elements.complex.RadioButtons;
5+
import com.epam.jdi.light.elements.pageobjects.annotations.locators.UI;
6+
import com.epam.jdi.light.ui.html.elements.common.Text;
7+
8+
public class CheckBoxPage extends NewAngularPage {
9+
@UI("#basic-checkbox")
10+
public static Checkbox basicCheckbox;
11+
12+
@UI("#indeterminate-checkbox")
13+
public static Checkbox indeterminateCheckbox;
14+
15+
@UI("#disabled-checkbox")
16+
public static Checkbox disabledCheckbox;
17+
18+
@UI("#result-checkbox")
19+
public static Checkbox resultCheckbox;
20+
21+
@UI(".mat-mdc-radio-group")
22+
public static RadioButtons modeRadioGroup;
23+
24+
@UI("#checkbox-color1")
25+
public static Checkbox primaryColorCheckbox;
26+
27+
@UI("#checkbox-color2")
28+
public static Checkbox accentColorCheckbox;
29+
30+
@UI("#checkbox-color3")
31+
public static Checkbox warnColorCheckbox;
32+
33+
@UI("#checkbox-required-option")
34+
public static Checkbox requiredCheckbox;
35+
36+
@UI("//*[@class='error']")
37+
public static Text requiredCheckboxText;
38+
39+
}

jdi-light-angular-tests/src/main/java/io/github/com/pages/sections/CheckboxSection.java

Lines changed: 0 additions & 16 deletions
This file was deleted.
Lines changed: 77 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,104 @@
11
package io.github.epam.angular.tests.elements.common;
22

3+
import com.epam.jdi.light.angular.elements.enums.AngularColors;
34
import io.github.epam.TestsInit;
4-
import org.testng.annotations.BeforeMethod;
5-
import org.testng.annotations.Ignore;
5+
import org.testng.annotations.BeforeClass;
66
import org.testng.annotations.Test;
77

8-
import static io.github.com.StaticSite.angularPage;
9-
import static io.github.com.pages.sections.CheckboxSection.*;
10-
import static io.github.epam.site.steps.States.shouldBeLoggedIn;
8+
import static io.github.com.enums.CheckBoxAlignPosition.AFTER;
9+
import static io.github.com.enums.CheckBoxAlignPosition.BEFORE;
10+
import static com.jdiai.tools.Timer.waitCondition;
11+
12+
import static io.github.com.StaticSite.checkBoxPage;
13+
import static io.github.com.pages.CheckBoxPage.accentColorCheckbox;
14+
import static io.github.com.pages.CheckBoxPage.basicCheckbox;
15+
import static io.github.com.pages.CheckBoxPage.disabledCheckbox;
16+
import static io.github.com.pages.CheckBoxPage.indeterminateCheckbox;
17+
import static io.github.com.pages.CheckBoxPage.modeRadioGroup;
18+
import static io.github.com.pages.CheckBoxPage.primaryColorCheckbox;
19+
import static io.github.com.pages.CheckBoxPage.requiredCheckbox;
20+
import static io.github.com.pages.CheckBoxPage.requiredCheckboxText;
21+
import static io.github.com.pages.CheckBoxPage.resultCheckbox;
22+
import static io.github.com.pages.CheckBoxPage.warnColorCheckbox;
1123

12-
// TODO Move to the new page
13-
@Ignore
1424
public class CheckboxTests extends TestsInit {
15-
@BeforeMethod(alwaysRun = true)
25+
@BeforeClass(alwaysRun = true)
1626
public void before() {
17-
shouldBeLoggedIn();
18-
angularPage.open();
19-
disabledCheckbox.show();
27+
checkBoxPage.open();
28+
waitCondition((() -> checkBoxPage.isOpened()));
29+
checkBoxPage.checkOpened();
2030
}
2131

22-
@Test
23-
public void checkLabelValue() {
32+
@Test(description = "Test verifies label value of checkbox")
33+
public void checkLabelValueTest() {
2434
basicCheckbox.label().has().value("Check me!");
2535
resultCheckbox.label().has().value("I'm a checkbox");
2636
}
2737

28-
@Test
29-
public void basicCheckboxValidation() {
38+
@Test(description = "Test verifies initial checkbox state and selection")
39+
public void basicCheckboxValidationTest() {
40+
basicCheckbox.show();
3041
basicCheckbox.is().displayed().and().enabled().and().deselected();
31-
}
32-
33-
@Test
34-
public void checkBasicCheckbox() {
3542
basicCheckbox.check();
3643
basicCheckbox.is().selected();
44+
basicCheckbox.uncheck();
3745
}
3846

39-
@Test
40-
public void indeterminateTest() {
41-
indeterminateCheckbox.click();
47+
@Test(description = "Test verifies checkbox feature: indeterminate")
48+
public void indeterminateCheckBoxTest() {
49+
indeterminateCheckbox.show();
50+
indeterminateCheckbox.check();
4251
resultCheckbox.is().indeterminate();
52+
indeterminateCheckbox.uncheck();
53+
basicCheckbox.is().notIndeterminate();
4354
}
4455

45-
@Test
46-
public void disabledOption() {
47-
disabledCheckbox.click();
56+
@Test(description = "Test verifies checkbox disabled state")
57+
public void disabledOptionCheckBoxTest() {
58+
disabledCheckbox.check();
4859
resultCheckbox.is().disabled();
60+
disabledCheckbox.uncheck();
61+
resultCheckbox.is().enabled();
4962
}
5063

51-
@Test
52-
public void configurableCheckboxTest() {
53-
indeterminateCheckbox.check();
54-
alignBeforeRadioButton.click();
55-
resultCheckbox.is().indeterminate().and().cssClass("mat-checkbox-label-before");
64+
@Test(description = "Test verifies checkbox align positions")
65+
public void alignPositionsCheckboxTest() {
66+
modeRadioGroup.click(BEFORE.getAlignPosition());
67+
resultCheckbox.is().alignedBefore();
68+
modeRadioGroup.click(AFTER.getAlignPosition());
69+
resultCheckbox.is().alignedAfter();
70+
}
71+
72+
@Test(description = "Test verifies checkbox feature: required option")
73+
public void isRequiredCheckboxTest() {
74+
requiredCheckbox.show();
75+
requiredCheckbox.is().required();
76+
requiredCheckboxText.has().text("Checkbox should be checked!");
77+
requiredCheckbox.check();
78+
requiredCheckboxText.is().notVisible();
79+
requiredCheckbox.uncheck();
80+
basicCheckbox.is().notRequired();
81+
warnColorCheckbox.is().notRequired();
82+
}
83+
84+
@Test(description = "Verifies checkbox colors as Angular colors")
85+
public void angularColorCheckBoxTest() {
86+
//Check color for checkboxes with attribute 'color'
87+
primaryColorCheckbox.has().angularColor(AngularColors.PRIMARY);
88+
accentColorCheckbox.has().angularColor(AngularColors.ACCENT);
89+
warnColorCheckbox.has().angularColor(AngularColors.WARN);
90+
//Check color for checkbox without attribute 'color'
91+
requiredCheckbox.has().angularColor(AngularColors.ACCENT);
5692
}
93+
94+
@Test(description = "Verifies checkbox colors as strings")
95+
public void colorCheckBoxTest() {
96+
//Check color for checkboxes with attribute 'color'
97+
primaryColorCheckbox.has().color("primary");
98+
accentColorCheckbox.has().color("accent");
99+
warnColorCheckbox.has().color("warn");
100+
//Check color for checkbox without attribute 'color'
101+
requiredCheckbox.has().color("accent");
102+
}
103+
57104
}
Lines changed: 49 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.epam.jdi.light.angular.asserts;
22

33
import com.epam.jdi.light.angular.elements.common.Checkbox;
4+
import com.epam.jdi.light.angular.elements.enums.AngularColors;
45
import com.epam.jdi.light.asserts.generic.UIAssert;
56
import com.epam.jdi.light.common.JDIAction;
67
import org.hamcrest.Matchers;
@@ -10,33 +11,76 @@
1011
public class CheckboxAssert extends UIAssert<CheckboxAssert, Checkbox> {
1112
@JDIAction("Assert that '{name}' is selected")
1213
public CheckboxAssert selected() {
13-
jdiAssert(element().isSelected(), Matchers.is(true));
14+
jdiAssert(element().isSelected(), Matchers.is(true), "Checkbox is not selected");
1415
return this;
1516
}
1617

1718
@JDIAction("Assert that '{name}' is not selected")
1819
public CheckboxAssert deselected() {
19-
jdiAssert(element().isSelected(), Matchers.is(false));
20+
jdiAssert(element().isSelected(), Matchers.is(false), "Checkbox is selected");
2021
return this;
2122
}
2223

2324
@JDIAction("Assert that '{name}' is indeterminate")
2425
public CheckboxAssert indeterminate() {
25-
jdiAssert(element().isIndeterminate(), Matchers.is(true));
26+
jdiAssert(element().isIndeterminate(), Matchers.is(true), "Checkbox is determinate");
27+
return this;
28+
}
29+
30+
@JDIAction("Assert that '{name}' is not indeterminate")
31+
public CheckboxAssert notIndeterminate() {
32+
jdiAssert(element().isIndeterminate(), Matchers.is(false), "Checkbox is indeterminate");
2633
return this;
2734
}
2835

2936
@JDIAction("Assert that '{name}' is enabled")
3037
@Override
3138
public CheckboxAssert enabled() {
32-
jdiAssert(element().isEnabled(), Matchers.is(true));
39+
jdiAssert(element().isEnabled(), Matchers.is(true), "Checkbox is disabled");
3340
return this;
3441
}
3542

3643
@JDIAction("Assert that '{name}' is disabled")
3744
@Override
3845
public CheckboxAssert disabled() {
39-
jdiAssert(element().isDisabled(), Matchers.is(true));
46+
jdiAssert(element().isDisabled(), Matchers.is(true), "Checkbox is enabled");
47+
return this;
48+
}
49+
50+
@JDIAction("Assert that '{name}' is aligned in before position")
51+
public CheckboxAssert alignedBefore() {
52+
jdiAssert(element().isAlignedBefore(), Matchers.is(true), "Checkbox is aligned after");
53+
return this;
54+
}
55+
56+
@JDIAction("Assert that '{name}' is aligned in after position")
57+
public CheckboxAssert alignedAfter() {
58+
jdiAssert(element().isAlignedBefore(), Matchers.is(false), "Checkbox is aligned before");
59+
return this;
60+
}
61+
62+
@JDIAction("Assert that '{name}' is required")
63+
public CheckboxAssert required() {
64+
jdiAssert(element().isRequired(), Matchers.is(true), "Checkbox does not have feature: required");
65+
return this;
66+
}
67+
68+
@JDIAction("Assert that '{name}' is not required")
69+
public CheckboxAssert notRequired() {
70+
jdiAssert(element().isRequired(), Matchers.is(false), "Checkbox has feature: required");
4071
return this;
4172
}
73+
74+
@JDIAction("Assert that '{name}' angular color is '{0}'")
75+
public CheckboxAssert angularColor(AngularColors expectedColor) {
76+
jdiAssert(element().color(), Matchers.is(expectedColor));
77+
return this;
78+
}
79+
80+
@JDIAction("Assert that '{name}' color is '{0}'")
81+
public CheckboxAssert color(String expectedColor) {
82+
jdiAssert(element().color().getColor(), Matchers.is(expectedColor));
83+
return this;
84+
}
85+
4286
}

0 commit comments

Comments
 (0)