Skip to content
This repository has been archived by the owner on Dec 17, 2020. It is now read-only.

Commit

Permalink
Correct link usage for productionMode (#432)
Browse files Browse the repository at this point in the history
* Correct link usage for productionMode

Fix Test for both modes
  • Loading branch information
ZheSun88 authored and gilberto-torrezan committed Apr 5, 2018
1 parent 7ad01f0 commit 5169ce7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import com.vaadin.flow.dom.ElementFactory;
import com.vaadin.flow.router.RouterLink;
import com.vaadin.flow.router.legacy.LocationChangeEvent;
import com.vaadin.flow.server.VaadinServlet;
import com.vaadin.flow.server.VaadinServletService;

/**
Expand Down Expand Up @@ -67,8 +68,10 @@ public ResourcesView() {
content.setClassName("content");

HtmlContainer links = new HtmlContainer("ul");
links.add(createLink("", "<none>"));
links.add(createLink("frontend/images/vaadin-logo-small.png"));
links.add(createLink("", "<none>", "none"));
links.add(createLink(VaadinServlet.getCurrent()
.resolveResource("frontend://images/vaadin-logo-small.png"),
"logo"));

HtmlContainer header = new HtmlContainer("p");
HtmlContainer strong = new HtmlContainer("strong");
Expand All @@ -83,13 +86,15 @@ public ResourcesView() {
add(content);
}

private static Component createLink(String resource) {
return createLink(resource, resource);
private static Component createLink(String resource, String id) {
return createLink(resource, resource, id);
}

private static Component createLink(String resource, String caption) {
private static Component createLink(String resource, String caption,
String id) {
RouterLink link = new RouterLink(caption, ResourcesView.class,
resource);
link.setId(id);
HtmlContainer li = new HtmlContainer("li");
li.add(link);
return li;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Map;
import java.util.stream.Collectors;

import org.hamcrest.CoreMatchers;
import org.junit.Assert;
import org.junit.Test;
import org.openqa.selenium.By;
Expand Down Expand Up @@ -124,16 +125,11 @@ public void testWildcardView() {
.findElement(By.xpath("./*[4]"));
Assert.assertEquals("No resource selected", selectedResource.getText());

getContent()
.findElement(
By.xpath(
"//a[text()='frontend/images/vaadin-logo-small.png']"))
.click();
assertLocation("resource/frontend/images/vaadin-logo-small.png");
getContent().findElement(By.id("logo")).click();

WebElement iframe = findElement(By.xpath("//iframe"));
assertLocation("frontend/images/vaadin-logo-small.png",
iframe.getAttribute("src"));
Assert.assertThat(iframe.getAttribute("src"),
CoreMatchers.containsString("images/vaadin-logo-small.png"));
}

@Test
Expand Down

0 comments on commit 5169ce7

Please sign in to comment.