Search in sources :

Example 1 with VAADIN_MAPPING

use of com.vaadin.flow.server.Constants.VAADIN_MAPPING in project flow by vaadin.

the class BootstrapHandlerTest method index_appended_to_head_in_npm.

@Test
public void index_appended_to_head_in_npm() throws InvalidRouteConfigurationException {
    initUI(testUI, createVaadinRequest(), Collections.singleton(AliasLayout.class));
    Document page = pageBuilder.getBootstrapPage(new BootstrapContext(request, null, session, testUI, this::contextRootRelativePath));
    Elements allElements = page.head().getAllElements();
    Assert.assertTrue("index.js should be added to head for ES6 browsers. (type module with crossorigin)", allElements.stream().map(Object::toString).anyMatch(element -> element.equals("<script type=\"module\" src=\"./" + VAADIN_MAPPING + "build/vaadin-bundle-1111.cache.js\" data-app-id=\"" + testUI.getInternals().getAppId() + "\" crossorigin></script>")));
}
Also used : CoreMatchers(org.hamcrest.CoreMatchers) Arrays(java.util.Arrays) Component(com.vaadin.flow.component.Component) JavaScript(com.vaadin.flow.component.dependency.JavaScript) Inline(com.vaadin.flow.component.page.Inline) BootstrapContext(com.vaadin.flow.server.BootstrapHandler.BootstrapContext) URL(java.net.URL) TargetElement(com.vaadin.flow.component.page.TargetElement) Registration(com.vaadin.flow.shared.Registration) INDEX_HTML(com.vaadin.flow.server.frontend.FrontendUtils.INDEX_HTML) PageTitle(com.vaadin.flow.router.PageTitle) Router(com.vaadin.flow.router.Router) Route(com.vaadin.flow.router.Route) RouteAlias(com.vaadin.flow.router.RouteAlias) VAADIN_WEBAPP_RESOURCES(com.vaadin.flow.server.Constants.VAADIN_WEBAPP_RESOURCES) PushMode(com.vaadin.flow.shared.communication.PushMode) ByteArrayInputStream(java.io.ByteArrayInputStream) Locale(java.util.Locale) Element(org.jsoup.nodes.Element) After(org.junit.After) Lookup(com.vaadin.flow.di.Lookup) UI(com.vaadin.flow.component.UI) VAADIN_MAPPING(com.vaadin.flow.server.Constants.VAADIN_MAPPING) Set(java.util.Set) StandardCharsets(java.nio.charset.StandardCharsets) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) ApplicationConfiguration(com.vaadin.flow.server.startup.ApplicationConfiguration) MatcherAssert(org.hamcrest.MatcherAssert) Assert.assertFalse(org.junit.Assert.assertFalse) Document(org.jsoup.nodes.Document) LoadMode(com.vaadin.flow.shared.ui.LoadMode) BodySize(com.vaadin.flow.component.page.BodySize) Optional(java.util.Optional) Elements(org.jsoup.select.Elements) ApplicationConstants(com.vaadin.flow.shared.ApplicationConstants) MockDeploymentConfiguration(com.vaadin.tests.util.MockDeploymentConfiguration) TestRouteRegistry(com.vaadin.flow.router.TestRouteRegistry) VaadinUriResolver(com.vaadin.flow.shared.VaadinUriResolver) Dependency(com.vaadin.flow.shared.ui.Dependency) AtomicReference(java.util.concurrent.atomic.AtomicReference) LinkedHashMap(java.util.LinkedHashMap) HttpServletRequest(javax.servlet.http.HttpServletRequest) Tag(com.vaadin.flow.component.Tag) Location(com.vaadin.flow.router.Location) Before(org.junit.Before) QueryParameters(com.vaadin.flow.router.QueryParameters) Text(com.vaadin.flow.component.Text) RouterLayout(com.vaadin.flow.router.RouterLayout) Html(com.vaadin.flow.component.Html) StyleSheet(com.vaadin.flow.component.dependency.StyleSheet) Meta(com.vaadin.flow.component.page.Meta) TestVaadinServletService(com.vaadin.flow.server.MockServletServiceSessionSetup.TestVaadinServletService) FileOutputStream(java.io.FileOutputStream) Assert.assertTrue(org.junit.Assert.assertTrue) IOException(java.io.IOException) Test(org.junit.Test) ResourceProvider(com.vaadin.flow.di.ResourceProvider) Mockito.when(org.mockito.Mockito.when) File(java.io.File) Mockito(org.mockito.Mockito) Rule(org.junit.Rule) RouteConfiguration(com.vaadin.flow.router.RouteConfiguration) FeatureFlags(com.vaadin.experimental.FeatureFlags) Assert(org.junit.Assert) Collections(java.util.Collections) Viewport(com.vaadin.flow.component.page.Viewport) TemporaryFolder(org.junit.rules.TemporaryFolder) ParentLayout(com.vaadin.flow.router.ParentLayout) Assert.assertEquals(org.junit.Assert.assertEquals) InputStream(java.io.InputStream) BootstrapContext(com.vaadin.flow.server.BootstrapHandler.BootstrapContext) Document(org.jsoup.nodes.Document) Elements(org.jsoup.select.Elements) Test(org.junit.Test)

Aggregations

FeatureFlags (com.vaadin.experimental.FeatureFlags)1 Component (com.vaadin.flow.component.Component)1 Html (com.vaadin.flow.component.Html)1 Tag (com.vaadin.flow.component.Tag)1 Text (com.vaadin.flow.component.Text)1 UI (com.vaadin.flow.component.UI)1 JavaScript (com.vaadin.flow.component.dependency.JavaScript)1 StyleSheet (com.vaadin.flow.component.dependency.StyleSheet)1 BodySize (com.vaadin.flow.component.page.BodySize)1 Inline (com.vaadin.flow.component.page.Inline)1 Meta (com.vaadin.flow.component.page.Meta)1 TargetElement (com.vaadin.flow.component.page.TargetElement)1 Viewport (com.vaadin.flow.component.page.Viewport)1 Lookup (com.vaadin.flow.di.Lookup)1 ResourceProvider (com.vaadin.flow.di.ResourceProvider)1 Location (com.vaadin.flow.router.Location)1 PageTitle (com.vaadin.flow.router.PageTitle)1 ParentLayout (com.vaadin.flow.router.ParentLayout)1 QueryParameters (com.vaadin.flow.router.QueryParameters)1 Route (com.vaadin.flow.router.Route)1