blob: d01f7214ad4a99574858242ff7bac527059882fd (
plain)
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
|
package com.vaadin.tests.components.datefield;
import org.junit.Test;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.ui.ExpectedConditions;
import com.vaadin.testbench.By;
import com.vaadin.testbench.elements.ButtonElement;
import com.vaadin.testbench.elements.CheckBoxElement;
import com.vaadin.testbench.elements.DateTimeFieldElement;
import com.vaadin.tests.tb3.SingleBrowserTest;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class DateTimeFieldWeekDaysTest extends SingleBrowserTest {
@Test
public void testFiLocale_weekNumbersVisible() {
openTestURL();
openPopupAndValidateWeekNumbers();
}
@Test
public void testToggleWeekNumbers_renderedCorrectly() {
openTestURL();
openPopupAndValidateWeekNumbers();
$(CheckBoxElement.class).first().click();
assertFalse("Checkbox is selected even though should be unselected.",
$(CheckBoxElement.class).first().isChecked());
openPopupAndValidateNoWeeknumbers();
}
@Test
public void testLocaleChangeToEnglish_removesWeekNumbers() {
openTestURL();
openPopupAndValidateWeekNumbers();
$(ButtonElement.class).id("english").click();
openPopupAndValidateNoWeeknumbers();
}
@Test
public void testChangeBackToFinnish_weekNumbersVisible() {
openTestURL();
$(ButtonElement.class).id("english").click();
openPopupAndValidateNoWeeknumbers();
$(ButtonElement.class).id("finnish").click();
openPopupAndValidateWeekNumbers();
}
private void openPopupAndValidateWeekNumbers() {
WebElement popupButton = $(DateTimeFieldElement.class).first()
.findElement(By.className("v-datefield-button"));
// Open date popup
popupButton.click();
sleep(100);
waitUntil(ExpectedConditions.visibilityOfElementLocated(
org.openqa.selenium.By.className("v-datefield-popup")));
assertFalse("No week numbers found for date field!",
findElements(
By.className("v-datefield-calendarpanel-weeknumber"))
.isEmpty());
// Close popup
popupButton.click();
sleep(100);
}
private void openPopupAndValidateNoWeeknumbers() {
WebElement popupButton = $(DateTimeFieldElement.class).first()
.findElement(By.className("v-datefield-button"));
// Open date popup
popupButton.click();
sleep(100);
waitUntil(ExpectedConditions.visibilityOfElementLocated(
org.openqa.selenium.By.className("v-datefield-popup")));
assertTrue("Week numbers still found in calendar popup!",
findElements(
By.className("v-datefield-calendarpanel-weeknumber"))
.isEmpty());
// Close popup
popupButton.click();
sleep(100);
}
}
|