Skip to content

Commit da91de8

Browse files
committed
Add integration tests
1 parent 86cbfe6 commit da91de8

File tree

5 files changed

+114
-21
lines changed

5 files changed

+114
-21
lines changed

drivers.xml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
2+
<root>
3+
<windows>
4+
<driver id="googlechrome">
5+
<version id="78.0.3904.70">
6+
<bitrate thirtytwobit="true" sixtyfourbit="true">
7+
<filelocation>https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_win32.zip</filelocation>
8+
<hash>26705e683632c6e1f9c62179b6143b409f4d7681</hash>
9+
<hashtype>sha1</hashtype>
10+
</bitrate>
11+
</version>
12+
</driver>
13+
</windows>
14+
<linux>
15+
<driver id="googlechrome">
16+
<version id="78.0.3904.70">
17+
<bitrate sixtyfourbit="true">
18+
<filelocation>https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_linux64.zip</filelocation>
19+
<hash>63e13e5f0df96af1cc3a2006c00b2f1871b62caf</hash>
20+
<hashtype>sha1</hashtype>
21+
</bitrate>
22+
</version>
23+
</driver>
24+
</linux>
25+
<osx>
26+
<driver id="googlechrome">
27+
<version id="78.0.3904.70">
28+
<bitrate sixtyfourbit="true">
29+
<filelocation>https://chromedriver.storage.googleapis.com/78.0.3904.70/chromedriver_mac64.zip</filelocation>
30+
<hash>ce06a7d3a9d18b3d054d3b4c3c32d2cd74e81a91</hash>
31+
<hashtype>sha1</hashtype>
32+
</bitrate>
33+
</version>
34+
</driver>
35+
</osx>
36+
</root>

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@
103103
<artifactId>vaadin-testbench</artifactId>
104104
<scope>test</scope>
105105
</dependency>
106+
<dependency>
107+
<groupId>org.hamcrest</groupId>
108+
<artifactId>hamcrest-library</artifactId>
109+
<version>1.3</version>
110+
<scope>test</scope>
111+
</dependency>
106112
</dependencies>
107113

108114
<build>

src/test/java/org/vaadin/ext/javier/AbstractViewTest.java renamed to src/test/java/com/flowingcode/addons/applayout/integration/AbstractViewTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package org.vaadin.ext.javier;
1+
package com.flowingcode.addons.applayout.integration;
22

33
import org.junit.Before;
44
import org.junit.Rule;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package com.flowingcode.addons.applayout.integration;
2+
3+
import static org.hamcrest.Matchers.empty;
4+
import static org.hamcrest.Matchers.is;
5+
import static org.hamcrest.Matchers.not;
6+
import static org.junit.Assert.assertThat;
7+
8+
import java.util.List;
9+
10+
import org.hamcrest.Description;
11+
import org.hamcrest.Matcher;
12+
import org.hamcrest.TypeSafeDiagnosingMatcher;
13+
import org.junit.Test;
14+
import org.openqa.selenium.By;
15+
import org.openqa.selenium.WebElement;
16+
17+
import com.vaadin.testbench.TestBenchElement;
18+
19+
public class ViewIT extends AbstractViewTest {
20+
21+
private Matcher<TestBenchElement> hasBeenUpgradedToCustomElement = new TypeSafeDiagnosingMatcher<TestBenchElement>() {
22+
23+
@Override
24+
public void describeTo(Description description) {
25+
description.appendText("a custom element");
26+
}
27+
28+
@Override
29+
protected boolean matchesSafely(TestBenchElement item, Description mismatchDescription) {
30+
String script = "let s=arguments[0].shadowRoot; return !!(s&&s.childElementCount)";
31+
if ((Boolean)item.getCommandExecutor().executeScript(script, item))
32+
return true;
33+
else {
34+
mismatchDescription.appendText(item.getTagName()+" ");
35+
mismatchDescription.appendDescriptionOf(is(not(this)));
36+
return false;
37+
}
38+
}
39+
40+
};
41+
42+
@Test
43+
public void componentWorks() {
44+
TestBenchElement header = $("app-header").first();
45+
TestBenchElement drawer = $("app-drawer").first();
46+
47+
assertThat(header, hasBeenUpgradedToCustomElement);
48+
assertThat(drawer, hasBeenUpgradedToCustomElement);
49+
50+
TestBenchElement toolbar = header.findElement(By.tagName("app-toolbar"));
51+
assertThat(toolbar, hasBeenUpgradedToCustomElement);
52+
53+
TestBenchElement menu = toolbar.findElement(By.cssSelector("paper-icon-button[icon='menu']"));
54+
toolbar.findElement(By.cssSelector("img.applogo"));
55+
toolbar.findElement(By.cssSelector("div[main-title]"));
56+
toolbar.findElement(By.cssSelector("paper-icon-button[role='button'][icon='settings']"));
57+
58+
assertThat(menu, hasBeenUpgradedToCustomElement);
59+
60+
TestBenchElement listbox = drawer.findElement(By.cssSelector("paper-listbox"));
61+
assertThat(listbox, hasBeenUpgradedToCustomElement);
62+
63+
List<WebElement> items = listbox.findElements(By.cssSelector("*"));
64+
assertThat(items, is(not(empty())));
65+
66+
for (WebElement item : items) {
67+
assertThat((TestBenchElement)item, hasBeenUpgradedToCustomElement);
68+
}
69+
}
70+
71+
}

src/test/java/org/vaadin/ext/javier/ViewIT.java

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)