use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method body_size_adds_styles_for_body.
// 2344
@Test
public void body_size_adds_styles_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(BodySizeAnnotated.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style from @BodySize", styleTag.get().toString().startsWith("<style type=\"text/css\">body {height:100vh;width:100vw;margin:0;}"));
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method theme_contents_are_not_appended_to_head_for_root_route.
// 3333
@Test
public void theme_contents_are_not_appended_to_head_for_root_route() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(MyAliasThemeTest.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Assert.assertFalse("Page head should not contain any Lumo imports.", page.head().toString().contains("vaadin-lumo"));
Assert.assertFalse("Page body should not have custom styles", page.body().toString().contains("<custom-style>"));
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method initUI.
private void initUI(UI ui, VaadinRequest request) {
this.request = request;
service.init();
ui.doInit(request, 0);
context = new BootstrapContext(request, null, session, ui);
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method page_configurator_inlines_prepend_javascript_from_file.
// 3036
@Test
public void page_configurator_inlines_prepend_javascript_from_file() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(InitialPageConfiguratorPrependFile.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
// Note element 0 is the full head element.
assertStringEquals("Content javascript should have been prepended to head element", "<script type=\"text/javascript\">window.messages = window.messages || [];\n" + "window.messages.push(\"inline.js\");</script>", allElements.get(1).toString());
}
use of com.vaadin.flow.server.BootstrapHandler.BootstrapContext in project flow by vaadin.
the class BootstrapHandlerTest method no_body_size_or_page_configurator_still_adds_margin_for_body.
// 2344
@Test
public void no_body_size_or_page_configurator_still_adds_margin_for_body() throws InvalidRouteConfigurationException {
initUI(testUI, createVaadinRequest(), Collections.singleton(RootNavigationTarget.class));
Document page = BootstrapHandler.getBootstrapPage(new BootstrapContext(request, null, session, testUI));
Elements allElements = page.head().getAllElements();
Optional<Element> styleTag = allElements.stream().filter(element -> element.tagName().equals("style")).findFirst();
Assert.assertTrue("Expected a style element in head.", styleTag.isPresent());
Assert.assertTrue("The first style tag should start with body style containing margin", styleTag.get().toString().startsWith("<style type=\"text/css\">body {margin:0;}"));
}
Aggregations