Search in sources :

Example 1 with ViewTest

use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.

the class InMemoryFeatureManagerTest method ensureDisablingViewPreventsItFromBeingRegistered.

@ViewTest
void ensureDisablingViewPreventsItFromBeingRegistered(@Context TestContext $) {
    val descriptor = new FeatureDescriptor("test.view.feature", "Test View Feature", ":application:modules:module-management:test-view", "Cool feature descriptor");
    featureManager.registerFeature(descriptor);
    assertTrue(featureManager.enable("test.view.feature"));
    $.navigate(TestFeatureView.class);
    $.flush();
    var button = $.selectFirst("vaadin-button[text*=test]", Button.class);
    assertTrue(button.isPresent());
    featureManager.disable("test.view.feature");
    $.navigate(MainView.class);
    $.navigate(TestFeatureView.class);
    button = $.selectFirst("vaadin-button[text*=test]", Button.class);
    assertFalse(button.isPresent());
}
Also used : lombok.val(lombok.val) FeatureDescriptor(com.aire.features.FeatureDescriptor) Button(com.vaadin.flow.component.button.Button) ViewTest(com.aire.ux.test.ViewTest)

Example 2 with ViewTest

use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureRegisteringRouteWorks.

@ViewTest
@DirtiesContext
void ensureRegisteringRouteWorks(@Autowired ExtensionRegistry registry, @Context TestContext $) {
    assertThrows(NotFoundException.class, () -> UI.getCurrent().navigate(MainNavigationComponent.class));
    val reg = registry.register(RouteDefinition.global(MainNavigationComponent.class));
    UI.getCurrent().navigate(MainNavigationComponent.class);
    reg.remove();
    assertThrows(NotFoundException.class, () -> UI.getCurrent().navigate(MainNavigationComponent.class));
}
Also used : lombok.val(lombok.val) MainNavigationComponent(io.sunshower.zephyr.ui.layout.scenario1.MainNavigationComponent) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 3 with ViewTest

use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureRegisteringSimpleComponentWorks.

@ViewTest
@DirtiesContext
void ensureRegisteringSimpleComponentWorks(@Autowired UserInterface ui, @Context TestContext $) {
    val extension = new DefaultComponentExtension<>(":management-menu", (NavigationBar parent) -> {
        val button = spy(new Button("Hello"));
        parent.add(button);
    });
    var button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertFalse(button.isPresent());
    val registration = ui.register(Selection.path(":main:navigation"), extension);
    $.flush();
    val menu = ui.selectFirst(Selection.path(":main:navigation:management-menu"));
    assertNotNull(menu);
    button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertTrue(button.isPresent());
    registration.close();
    $.flush(true);
    assertEquals(0, ui.getExtensionRegistry().getExtensionCount());
    button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
    assertFalse(button.isPresent());
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Button(com.vaadin.flow.component.button.Button) DefaultComponentExtension(com.aire.ux.DefaultComponentExtension) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 4 with ViewTest

use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureRegistrationWorksWithComponents.

@ViewTest
@DirtiesContext
void ensureRegistrationWorksWithComponents(@Context TestContext $, @Autowired UserInterface userInterface) {
    val registration = userInterface.register(Selection.path(":main-2:navbar"), Extensions.create(":sup", (@NonNull NavigationBar b) -> {
        b.add(new Button("hello"));
    }));
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    val reg2 = userInterface.register(Mode.Global, MainNavigationComponent.class);
    $.navigate(MainNavigationComponent.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isPresent());
    registration.close();
    $.navigate(MainView.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    $.navigate(MainNavigationComponent.class);
    assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
    reg2.remove();
}
Also used : lombok.val(lombok.val) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Button(com.vaadin.flow.component.button.Button) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 5 with ViewTest

use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureSelectionWorks.

@ViewTest
void ensureSelectionWorks(@Autowired UserInterface ui) {
    val result = ui.selectFirst(Selection.path(":main:navigation", MainView.class));
    assertTrue(result.isPresent());
    assertInstanceOf(NavigationBar.class, result.get());
}
Also used : lombok.val(lombok.val) MainView(io.sunshower.zephyr.MainView) ViewTest(com.aire.ux.test.ViewTest)

Aggregations

ViewTest (com.aire.ux.test.ViewTest)23 lombok.val (lombok.val)23 Navigate (com.aire.ux.test.Navigate)8 Routes (com.aire.ux.test.Routes)6 DirtiesContext (org.springframework.test.annotation.DirtiesContext)6 Button (com.vaadin.flow.component.button.Button)5 NavigationBar (io.sunshower.zephyr.ui.navigation.NavigationBar)3 DefaultComponentExtension (com.aire.ux.DefaultComponentExtension)2 Context (com.aire.ux.test.Context)2 Select (com.aire.ux.test.Select)2 TestContext (com.aire.ux.test.TestContext)2 Grid (com.vaadin.flow.component.grid.Grid)2 MainView (io.sunshower.zephyr.MainView)2 MainNavigationComponent (io.sunshower.zephyr.ui.layout.scenario1.MainNavigationComponent)2 Assertions.assertEquals (org.junit.jupiter.api.Assertions.assertEquals)2 Assertions.assertNotNull (org.junit.jupiter.api.Assertions.assertNotNull)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 FeatureDescriptor (com.aire.features.FeatureDescriptor)1 Extensions (com.aire.ux.Extensions)1 RouteDefinition (com.aire.ux.RouteDefinition)1