aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnna Koskinen <Ansku@users.noreply.github.com>2020-01-10 16:06:45 +0200
committerGitHub <noreply@github.com>2020-01-10 16:06:45 +0200
commitfe86bb59f4d56abd70861146ff2106415bc836a4 (patch)
tree32601df16dc4c43ca57386e6da0c6ac9d1b73a56
parent376131e16b10d07eea707fcacfa9b14b71fd971a (diff)
downloadvaadin-framework-fe86bb59f4d56abd70861146ff2106415bc836a4.tar.gz
vaadin-framework-fe86bb59f4d56abd70861146ff2106415bc836a4.zip
Convert DateFieldReadOnlyTest to not rely on screenshots. (#11867)
-rwxr-xr-xuitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__initial-date.pngbin13077 -> 0 bytes
-rwxr-xr-xuitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readonly-date.pngbin13237 -> 0 bytes
-rwxr-xr-xuitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readwrite-popup-date.pngbin26106 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__initial-date.pngbin11825 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readonly-date.pngbin11979 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readwrite-popup-date.pngbin24440 -> 0 bytes
-rwxr-xr-xuitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_initial-date.pngbin10114 -> 0 bytes
-rwxr-xr-xuitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readonly-date.pngbin10266 -> 0 bytes
-rwxr-xr-xuitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readwrite-popup-date.pngbin19115 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_initial-date.pngbin10908 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readonly-date.pngbin10908 -> 0 bytes
-rw-r--r--uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readwrite-popup-date.pngbin21406 -> 0 bytes
-rw-r--r--uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java61
13 files changed, 45 insertions, 16 deletions
diff --git a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__initial-date.png b/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__initial-date.png
deleted file mode 100755
index 720aabdb77..0000000000
--- a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__initial-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readonly-date.png b/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readonly-date.png
deleted file mode 100755
index 697a8b604d..0000000000
--- a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readonly-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readwrite-popup-date.png b/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readwrite-popup-date.png
deleted file mode 100755
index d015d1559d..0000000000
--- a/uitest/reference-screenshots/chrome/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Chrome__readwrite-popup-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__initial-date.png b/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__initial-date.png
deleted file mode 100644
index d53b04085d..0000000000
--- a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__initial-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readonly-date.png b/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readonly-date.png
deleted file mode 100644
index 3ac6d63d90..0000000000
--- a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readonly-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readwrite-popup-date.png b/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readwrite-popup-date.png
deleted file mode 100644
index 263e5e8432..0000000000
--- a/uitest/reference-screenshots/firefox/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_ANY_Firefox__readwrite-popup-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_initial-date.png b/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_initial-date.png
deleted file mode 100755
index 2914acda72..0000000000
--- a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_initial-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readonly-date.png b/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readonly-date.png
deleted file mode 100755
index 5958e10b90..0000000000
--- a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readonly-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readwrite-popup-date.png b/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readwrite-popup-date.png
deleted file mode 100755
index e4f5432709..0000000000
--- a/uitest/reference-screenshots/internetexplorer/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_Windows_InternetExplorer_11_readwrite-popup-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_initial-date.png b/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_initial-date.png
deleted file mode 100644
index 2df7757550..0000000000
--- a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_initial-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readonly-date.png b/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readonly-date.png
deleted file mode 100644
index 2df7757550..0000000000
--- a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readonly-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readwrite-popup-date.png b/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readwrite-popup-date.png
deleted file mode 100644
index 81dc1e3459..0000000000
--- a/uitest/reference-screenshots/phantomjs/DateFieldReadOnlyTest-readOnlyDateFieldPopupShouldNotOpen_LINUX_PhantomJS_1_readwrite-popup-date.png
+++ /dev/null
Binary files differ
diff --git a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java
index 9418a5011b..c927ed5661 100644
--- a/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java
+++ b/uitest/src/test/java/com/vaadin/tests/components/datefield/DateFieldReadOnlyTest.java
@@ -1,13 +1,18 @@
package com.vaadin.tests.components.datefield;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import java.io.IOException;
import org.junit.Test;
-import org.openqa.selenium.Keys;
+import org.openqa.selenium.ElementNotInteractableException;
+import org.openqa.selenium.WebElement;
import com.vaadin.testbench.By;
-import com.vaadin.testbench.elements.AbstractDateFieldElement;
import com.vaadin.testbench.elements.ButtonElement;
+import com.vaadin.testbench.elements.DateFieldElement;
import com.vaadin.tests.tb3.MultiBrowserTest;
public class DateFieldReadOnlyTest extends MultiBrowserTest {
@@ -17,27 +22,51 @@ public class DateFieldReadOnlyTest extends MultiBrowserTest {
throws IOException, InterruptedException {
openTestURL();
- compareScreen("initial-date");
+ DateFieldElement df = $(DateFieldElement.class).first();
+ WebElement dfButton = df
+ .findElement(By.className("v-datefield-button"));
+
+ // ensure initial read-only state works and pop-up cannot be opened
+ assertTrue(df.hasClassName("v-readonly"));
+ assertEquals("none", dfButton.getCssValue("display"));
+ assertTrue(findElements(By.className("v-datefield-calendarpanel"))
+ .isEmpty());
+
+ assertFalse(openPopup(df));
+ assertTrue(findElements(By.className("v-datefield-calendarpanel"))
+ .isEmpty());
+
+ // ensure read-only state can be removed and the component is still
+ // functional
toggleReadOnly();
+ assertFalse(df.hasClassName("v-readonly"));
+ assertEquals("inline-block", dfButton.getCssValue("display"));
- openPopup();
- compareScreen("readwrite-popup-date");
+ assertTrue(openPopup(df));
+ assertEquals(1,
+ findElements(By.className("v-datefield-calendarpanel")).size());
- closePopup();
+ // ensure read-only state can be re-applied, pop-up is closed and cannot
+ // be re-opened
toggleReadOnly();
- compareScreen("readonly-date");
- }
+ assertTrue(df.hasClassName("v-readonly"));
+ assertEquals("none", dfButton.getCssValue("display"));
+ assertTrue(findElements(By.className("v-datefield-calendarpanel"))
+ .isEmpty());
- private void closePopup() {
- findElement(By.className("v-datefield-calendarpanel"))
- .sendKeys(Keys.RETURN);
+ assertFalse(openPopup(df));
+ assertTrue(findElements(By.className("v-datefield-calendarpanel"))
+ .isEmpty());
}
- private void openPopup() {
- // waiting for openPopup() in TB4 beta1:
- // http://dev.vaadin.com/ticket/13766
- $(AbstractDateFieldElement.class).first()
- .findElement(By.tagName("button")).click();
+ private boolean openPopup(DateFieldElement df) {
+ // ensure the hidden button cannot be interacted with
+ try {
+ df.openPopup();
+ return true;
+ } catch (ElementNotInteractableException e) {
+ return false;
+ }
}
private void toggleReadOnly() {