/
SparklinesTests.java
119 lines (101 loc) · 4.72 KB
/
SparklinesTests.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
package io.github.epam.vuetify.tests.common;
import io.github.epam.TestsInit;
import io.github.epam.vuetify.tests.data.SparklinesDataProvider;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
import static com.jdiai.tools.Timer.waitCondition;
import static io.github.com.StaticSite.sparklinesPage;
import static io.github.com.pages.SparklinesPage.barSparkline;
import static io.github.com.pages.SparklinesPage.customLabelsSparkline;
import static io.github.com.pages.SparklinesPage.dashboardCardSparkline;
import static io.github.com.pages.SparklinesPage.fillSparkline;
import static io.github.com.pages.SparklinesPage.fillSparklineColorSwitches;
import static io.github.com.pages.SparklinesPage.fillSparklineFilledSwitch;
import static io.github.com.pages.SparklinesPage.fillSparklineRadiusSlider;
import static io.github.com.pages.SparklinesPage.fillSparklineWidthSlider;
import static io.github.com.pages.SparklinesPage.heartRateSparkline;
public class SparklinesTests extends TestsInit {
@BeforeClass
public void before() {
sparklinesPage.open();
waitCondition(() -> sparklinesPage.isOpened());
sparklinesPage.checkOpened();
}
@Test(dataProvider = "fillSparklineLinearGradientTestsData", dataProviderClass = SparklinesDataProvider.class,
description = "Test checks sparkline's linear gradient")
public void linearGradientSparklineTests(Map<String, String> expectedLinearGradientMap,
int gradientSwitchNumber) {
fillSparklineColorSwitches.get(gradientSwitchNumber).click();
fillSparkline.has().linearGradientMap(expectedLinearGradientMap);
}
@Test (description = "Test checks sparkline's path shape")
public void pathShapeSparklineTests() {
fillSparklineWidthSlider.setValue(1.0);
fillSparkline.has().lineWidth(1);
String pathShapeBeforeRadiusSliderInteraction = fillSparkline.getPathShape();
fillSparkline.has().pathShapeEqualTo(pathShapeBeforeRadiusSliderInteraction);
fillSparklineRadiusSlider.setValue(1.0);
fillSparkline.has().pathShapeNotEqualTo(pathShapeBeforeRadiusSliderInteraction);
}
@Test (description = "Test checks fill feature")
public void fillSparklineTests() {
fillSparkline.show();
fillSparkline.is().filled();
fillSparklineFilledSwitch.uncheck();
fillSparkline.is().notFilled();
}
@Test (description = "Test checks label prefix and postfix")
public void customLabelsSparklineTests() {
customLabelsSparkline.show();
customLabelsSparkline.has().labelsPrefixedWith("$");
dashboardCardSparkline.show();
dashboardCardSparkline.has().labelsPostfixedWith("m");
}
@Test (description = "Test checks linear gradient")
public void dashboardCardSparklineTests() {
Map<String, String> expectedLinearGradientMap = Collections.singletonMap("0", "currentColor");
dashboardCardSparkline.has().linearGradientMap(expectedLinearGradientMap);
}
@Test(description = "Check sparkline's type : type (trend/bars)")
public void typeSparklineTests() {
heartRateSparkline.show();
heartRateSparkline.is().trendline();
barSparkline.show();
barSparkline.is().bar();
}
@Test(description = "Check sparkline's height and width : height, width")
public void measurementsSparklineTests() {
barSparkline.show();
barSparkline.has().widthLessThan(1700)
.and().widthGreaterThan(800)
.and().heightLessThan(1000)
.and().heightGreaterThan(100);
}
@Test(description = "Check if sparkline has visible labels or not : show labels (y/n)")
public void labelsSparklineTests() {
barSparkline.show();
barSparkline.has().labels().and().labelTexts(Arrays.asList("1", "2", "3"));
heartRateSparkline.show();
heartRateSparkline.has().noLabels();
}
@Test(description = "Check sparkline's label font size : label size")
public void labelSizeSparklineTests() {
customLabelsSparkline.show();
customLabelsSparkline.has().labelFontSize(8);
}
@Test(description = "Check sparkline's line width : line width")
public void lineWidthSparklineTests() {
heartRateSparkline.show();
heartRateSparkline.has().lineWidth(3);
}
@Test(description = "Check sparkline's bars height and width")
public void barsHeightAndWidthSparklineTests() {
barSparkline.show();
barSparkline.has().barWidth(4)
.and().barsWidth(Arrays.asList(4, 4, 4))
.and().barsHeight(Arrays.asList(25, 50, 75));
}
}