Search in sources :

Example 16 with ViewTest

use of com.aire.ux.test.ViewTest 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)

Example 17 with ViewTest

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

the class PluginTabViewTest method ensurePluginTabViewIsInjectable.

@ViewTest
@Navigate("zephyr/management/modules/list")
void ensurePluginTabViewIsInjectable(@Context TestContext $) {
    val view = $.selectFirst("aire-tab-panel", TabPanel.class);
    assertTrue(view.isPresent());
}
Also used : lombok.val(lombok.val) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate)

Example 18 with ViewTest

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

the class CanvasTest method ensureInvocationAPIResultsInActionAvailableWhenAppliedThroughAction.

@ViewTest
void ensureInvocationAPIResultsInActionAvailableWhenAppliedThroughAction(@View Canvas canvas, @Context(mode = Mode.Spy) UI ui) {
    val result = VertexTemplate.newBuilder("test").width(100f).height(100f).create();
    val action = new AddVertexTemplateAction(() -> ui, result);
    action.apply(canvas.getModel());
}
Also used : lombok.val(lombok.val) AddVertexTemplateAction(io.sunshower.zephyr.ui.canvas.actions.AddVertexTemplateAction) ViewTest(com.aire.ux.test.ViewTest)

Example 19 with ViewTest

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

the class CanvasTest method ensureAddVerticesActionisInvokable.

@ViewTest
@DirtiesContext
void ensureAddVerticesActionisInvokable(@View Canvas canvas) {
    assertTrue(canvas.getModel().getVertices().isEmpty());
    val vertices = List.of(new Vertex());
    canvas.invoke(AddVerticesAction.class, vertices);
    assertEquals(1, canvas.getModel().getVertices().size());
}
Also used : lombok.val(lombok.val) DirtiesContext(org.springframework.test.annotation.DirtiesContext) ViewTest(com.aire.ux.test.ViewTest)

Example 20 with ViewTest

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

the class ModuleGridTest method ensureModuleGridHasCorrectLayout.

@ViewTest
void ensureModuleGridHasCorrectLayout(@Context TestContext context, @Context Instantiator instantiator) {
    val grid = instantiator.createComponent(ModuleGrid.class);
    val $ = context.downTo(grid);
    val columns = $.select(Grid.Column.class);
    assertEquals(columns.size(), 5);
}
Also used : lombok.val(lombok.val) Grid(com.vaadin.flow.component.grid.Grid) 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