Search in sources :

Example 11 with ViewTest

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

the class ExploratorySpringTest method ensureInteractingWithElementWorks.

@ViewTest
@Navigate("main")
void ensureInteractingWithElementWorks(@Autowired ApplicationContext applicationContext, @Select(".main") Element initialView, @Select(".main > vaadin-button") Button button, @Context TestContext context) {
    assertNotNull(applicationContext);
    assertEquals(0, initialView.getComponent().map(component -> (MainView) component).orElseThrow().getCount());
    button.click();
    val view = context.selectFirst(".main", MainView.class).get();
    assertEquals(view.getCount(), 1);
}
Also used : ViewTest(com.aire.ux.test.ViewTest) Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) Scenario1Configuration(com.aire.ux.spring.test.scenario1.Scenario1Configuration) AireTest(com.aire.ux.test.AireTest) lombok.val(lombok.val) Select(com.aire.ux.test.Select) Autowired(org.springframework.beans.factory.annotation.Autowired) EnableSpring(com.aire.ux.test.spring.EnableSpring) ApplicationContext(org.springframework.context.ApplicationContext) Context(com.aire.ux.test.Context) Inject(javax.inject.Inject) Test(org.junit.jupiter.api.Test) Navigate(com.aire.ux.test.Navigate) TestService(com.aire.ux.spring.test.scenario1.TestService) Button(com.vaadin.flow.component.button.Button) TestContext(com.aire.ux.test.TestContext) Routes(com.aire.ux.test.Routes) Element(com.vaadin.flow.dom.Element) ContextConfiguration(org.springframework.test.context.ContextConfiguration) MainView(com.aire.ux.spring.test.scenario1.MainView) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) lombok.val(lombok.val) MainView(com.aire.ux.spring.test.scenario1.MainView) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate)

Example 12 with ViewTest

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

the class NavigationTest method ensureRouteIsAvailable.

@Order(2)
@ViewTest
@Navigate("main")
@Routes(scanClassPackage = MainLayout.class)
void ensureRouteIsAvailable(@Context TestContext context) {
    val layout = context.selectFirst(MainLayout.class);
    assertTrue(layout.isPresent());
}
Also used : lombok.val(lombok.val) Order(org.junit.jupiter.api.Order) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate) Routes(com.aire.ux.test.Routes)

Example 13 with ViewTest

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

the class TopLevelVaadinTestCaseTest method ensureTestMethodGeneratesFrameWithCurrentMethod.

@ViewTest
@Navigate("test")
@Routes(scanPackage = "com.aire.ux.test.vaadin.scenarios.classroutes")
void ensureTestMethodGeneratesFrameWithCurrentMethod() throws NoSuchMethodException {
    val method = Frames.resolveCurrentFrame().getContext().getTestMethod();
    assertTrue(method.isPresent());
    val m = method.get();
    assertEquals(m, TopLevelVaadinTestCaseTest.class.getDeclaredMethod("ensureTestMethodGeneratesFrameWithCurrentMethod"));
}
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 14 with ViewTest

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

the class TopLevelVaadinTestCaseTest method ensureTestMethodGeneratesFrameWithCurrentMethod2.

@ViewTest
@Navigate("test")
@Routes(scanPackage = "com.aire.ux.test.vaadin.scenarios.classroutes")
void ensureTestMethodGeneratesFrameWithCurrentMethod2(@Select ClassScenarioRouteLayout layout) throws NoSuchMethodException {
    val method = Frames.resolveCurrentFrame().getContext().getTestMethod();
    assertTrue(method.isPresent());
    val m = method.get();
    assertEquals(m, TopLevelVaadinTestCaseTest.class.getDeclaredMethod("ensureTestMethodGeneratesFrameWithCurrentMethod2", ClassScenarioRouteLayout.class));
}
Also used : lombok.val(lombok.val) ClassScenarioRouteLayout(com.aire.ux.test.vaadin.scenarios.classroutes.ClassScenarioRouteLayout) ViewTest(com.aire.ux.test.ViewTest) Navigate(com.aire.ux.test.Navigate) Routes(com.aire.ux.test.Routes)

Example 15 with ViewTest

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

the class AddVerticesRemoteActionTest method ensureConnectingNodesWorks.

@ViewTest
@DirtiesContext
void ensureConnectingNodesWorks(@View Canvas canvas) {
    val source = new Vertex();
    val target = new Vertex();
    canvas.invoke(AddVerticesAction.class, List.of(source, target));
    assertEquals(2, canvas.getModel().getVertices().size());
    assertTrue(canvas.getModel().getEdges().isEmpty());
    canvas.invoke(ConnectVerticesAction.class, List.of(new Edge(source.getId(), target.getId())));
    assertEquals(1, canvas.getModel().getEdges().size());
}
Also used : lombok.val(lombok.val) Vertex(io.sunshower.zephyr.ui.canvas.Vertex) Edge(io.sunshower.zephyr.ui.canvas.Edge) DirtiesContext(org.springframework.test.annotation.DirtiesContext) 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