Search in sources :

Example 1 with UserInterface

use of com.aire.ux.UserInterface in project aire-components by aire-ux.

the class ApplicationLayoutTest method ensureActionManagerCanEnableAndDisableButtons.

@ViewTest
@DirtiesContext
void ensureActionManagerCanEnableAndDisableButtons(@Autowired UserInterface ui, @Context TestContext $) {
    val action = spy(Actions.create("ui.module.stop", (self) -> {
    }));
    ui.register(Selection.path(":main:navigation"), Extensions.create(":management-menu", (NavigationBar p) -> {
        val button = new Button("hello");
        action.addActionEventListener(Type.ActionEnabled, (eventType, event) -> {
            button.setEnabled(true);
        });
        action.addActionEventListener(Type.ActionDisabled, (eventType, event) -> {
            button.setEnabled(true);
        });
        p.add(button);
    }));
    action.enable();
    $.flush();
    assertTrue($.selectFirst("vaadin-button[enabled]", Button.class).isPresent());
    action.dispose();
}
Also used : lombok.val(lombok.val) Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ViewTest(com.aire.ux.test.ViewTest) DirtiesContext(org.springframework.test.annotation.DirtiesContext) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) BeforeEach(org.junit.jupiter.api.BeforeEach) NavigationBar(io.sunshower.zephyr.ui.navigation.NavigationBar) Extensions(com.aire.ux.Extensions) UserInterface(com.aire.ux.UserInterface) RouteDefinition(com.aire.ux.RouteDefinition) Select(com.aire.ux.test.Select) Autowired(org.springframework.beans.factory.annotation.Autowired) Mockito.spy(org.mockito.Mockito.spy) Context(com.aire.ux.test.Context) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TestContext(com.aire.ux.test.TestContext) Actions(com.aire.ux.actions.Actions) Routes(com.aire.ux.test.Routes) AireUITest(io.sunshower.zephyr.AireUITest) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) Type(com.aire.ux.actions.ActionEvent.Type) UI(com.vaadin.flow.component.UI) NotFoundException(com.vaadin.flow.router.NotFoundException) Mode(com.aire.ux.RouteDefinition.Mode) NonNull(lombok.NonNull) Assertions.assertInstanceOf(org.junit.jupiter.api.Assertions.assertInstanceOf) lombok.val(lombok.val) Selection(com.aire.ux.Selection) Navigate(com.aire.ux.test.Navigate) DefaultComponentExtension(com.aire.ux.DefaultComponentExtension) Button(com.vaadin.flow.component.button.Button) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) MainNavigationComponent(io.sunshower.zephyr.ui.layout.scenario1.MainNavigationComponent) MainView(io.sunshower.zephyr.MainView) ExtensionRegistry(com.aire.ux.ext.ExtensionRegistry) 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)

Aggregations

DefaultComponentExtension (com.aire.ux.DefaultComponentExtension)1 Extensions (com.aire.ux.Extensions)1 RouteDefinition (com.aire.ux.RouteDefinition)1 Mode (com.aire.ux.RouteDefinition.Mode)1 Selection (com.aire.ux.Selection)1 UserInterface (com.aire.ux.UserInterface)1 Type (com.aire.ux.actions.ActionEvent.Type)1 Actions (com.aire.ux.actions.Actions)1 ExtensionRegistry (com.aire.ux.ext.ExtensionRegistry)1 Context (com.aire.ux.test.Context)1 Navigate (com.aire.ux.test.Navigate)1 Routes (com.aire.ux.test.Routes)1 Select (com.aire.ux.test.Select)1 TestContext (com.aire.ux.test.TestContext)1 ViewTest (com.aire.ux.test.ViewTest)1 UI (com.vaadin.flow.component.UI)1 Button (com.vaadin.flow.component.button.Button)1 NotFoundException (com.vaadin.flow.router.NotFoundException)1 AireUITest (io.sunshower.zephyr.AireUITest)1 MainView (io.sunshower.zephyr.MainView)1