Search in sources :

Example 6 with ViewTest

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

the class ModuleGridTest method ensureModuleGridContainsDefaultPlugin.

@ViewTest
@SuppressWarnings({ "unchecked", "rawtypes" })
void ensureModuleGridContainsDefaultPlugin(@Context TestContext context, @Context Instantiator instantiator) {
    val grid = instantiator.createComponent(ModuleGrid.class);
    val $ = context.downTo(grid);
    val g = $.selectFirst(Grid.class).get();
    assertEquals(g.getDataProvider().size(new Query()), 1);
}
Also used : lombok.val(lombok.val) Query(com.vaadin.flow.data.provider.Query) Grid(com.vaadin.flow.component.grid.Grid) ViewTest(com.aire.ux.test.ViewTest)

Example 7 with ViewTest

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

the class CanvasTest method ensureAddingVertexListenerWorks.

@ViewTest
void ensureAddingVertexListenerWorks(@View Canvas canvas) {
    assertEquals(0, canvas.getModel().getListenerCount());
    val registration = canvas.addCellListener(EventType.Clicked, vertex -> {
    }, vertex -> vertex.getProperties().containsKey("hello"));
    canvas.onComponentEvent(mock(CanvasReadyEvent.class));
    assertEquals(1, canvas.getModel().getListenerCount());
    registration.remove();
    assertEquals(0, canvas.getModel().getListenerCount());
}
Also used : lombok.val(lombok.val) ViewTest(com.aire.ux.test.ViewTest)

Example 8 with ViewTest

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

the class CanvasTest method ensureCanvasInvocationAPIMakesSense.

@ViewTest
void ensureCanvasInvocationAPIMakesSense(@View Canvas canvas, @Context(mode = Mode.Spy) UI ui) throws IOException {
    val result = VertexTemplate.newBuilder("test").width(100f).height(100f).create();
    val method = ClientMethods.withUiSupplier(() -> ui).get("addVertexTemplate", VertexTemplate.class);
    val spiedElement = spy(canvas.getElement());
    doReturn(spiedElement).when(canvas).getElement();
    method.invoke(canvas, result);
    verify(canvas, atLeast(2)).getElement();
    verify(spiedElement).callJsFunction(eq("addVertexTemplate"), eq(writer.write(VertexTemplate.class, result)));
    Mockito.reset(ui);
}
Also used : lombok.val(lombok.val) ViewTest(com.aire.ux.test.ViewTest)

Example 9 with ViewTest

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

the class TopLevelVaadinTestCaseTest method ensureTestMethodWithViewTestGeneratesFrameEntryWithMethod.

@ViewTest
@Navigate("test")
@Routes(scanPackage = "com.aire.ux.test.vaadin.scenarios.classroutes")
void ensureTestMethodWithViewTestGeneratesFrameEntryWithMethod() {
    val method = Frames.resolveCurrentFrame().getContext().getTestMethod();
    assertTrue(method.isPresent());
}
Also used : lombok.val(lombok.val) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate) Routes(com.aire.ux.test.Routes)

Example 10 with ViewTest

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

the class ThemeTest method ensureThemeDecoratesButton.

@ViewTest
@Navigate("main")
void ensureThemeDecoratesButton(@Context TestContext context) {
    val result = context.selectFirst("aire-button.test-theme", TestButton.class);
    assertTrue(result.isPresent());
}
Also used : lombok.val(lombok.val) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate)

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