summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2014-10-04 00:03:38 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2014-11-10 13:20:11 +0200
commitfead7a7435a360776a93df55e5e9ca9e24fa3fd0 (patch)
treead8cef06f5ec6f1db4f4b5ecee4a68bbab44ffe1 /uitest
parentef8d1ecf8765ce68bbe69021b90f3377ef8d201a (diff)
downloadvaadin-framework-fead7a7435a360776a93df55e5e9ca9e24fa3fd0.tar.gz
vaadin-framework-fead7a7435a360776a93df55e5e9ca9e24fa3fd0.zip
Fix VCalendar to use correct year of week. (#14783)
Change-Id: Id55ad5ed620bd5c187b70ae2a2d0a4c4adea382a
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java39
-rw-r--r--uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java41
2 files changed, 80 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
new file mode 100644
index 0000000000..c74f2a53e3
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelection.java
@@ -0,0 +1,39 @@
+package com.vaadin.tests.components.calendar;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.tests.components.AbstractTestUI;
+import com.vaadin.ui.Calendar;
+
+public class CalendarWeekSelection extends AbstractTestUI {
+ @Override
+ protected void setup(VaadinRequest request) {
+ Calendar calendar = new Calendar();
+ calendar.setLocale(Locale.US);
+
+ try {
+ calendar.setStartDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2013-12-15"));
+ calendar.setEndDate(new SimpleDateFormat("yyyy-MM-dd")
+ .parse("2014-01-15"));
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+
+ addComponent(calendar);
+ }
+
+ @Override
+ protected Integer getTicketNumber() {
+ return 14783;
+ }
+
+ @Override
+ protected String getTestDescription() {
+ return "December 2013 - January 2014. Clicking the week 1 "
+ + "should open the week view for the first week of 2014.";
+ }
+}
diff --git a/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
new file mode 100644
index 0000000000..83f41994ae
--- /dev/null
+++ b/uitest/src/com/vaadin/tests/components/calendar/CalendarWeekSelectionTest.java
@@ -0,0 +1,41 @@
+package com.vaadin.tests.components.calendar;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+
+import java.util.List;
+
+import org.junit.Test;
+import org.openqa.selenium.WebElement;
+
+import com.vaadin.testbench.By;
+import com.vaadin.tests.tb3.MultiBrowserTest;
+
+public class CalendarWeekSelectionTest extends MultiBrowserTest {
+
+ @Test
+ public void correctYearIsSelected() {
+ openTestURL();
+
+ clickOnWeek("1");
+
+ assertThat(getFirstDayOfTheYear().getText(), is("Wednesday 1/1/14"));
+ }
+
+ private WebElement getFirstDayOfTheYear() {
+ WebElement header = findElement(By.className("v-calendar-header-week"));
+ List<WebElement> headerElements = header.findElements(By.tagName("td"));
+
+ // Wednesday is the first day of 2014.
+ return headerElements.get(4);
+ }
+
+ private void clickOnWeek(String week) {
+ for (WebElement e : findElements(By.className("v-calendar-week-number"))) {
+ if (e.getText().equals(week)) {
+ e.click();
+ break;
+ }
+ }
+ }
+} \ No newline at end of file