Search in sources :

Example 1 with Context

use of com.aire.ux.test.Context 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 2 with Context

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

Context (com.aire.ux.test.Context)2 Navigate (com.aire.ux.test.Navigate)2 Routes (com.aire.ux.test.Routes)2 Select (com.aire.ux.test.Select)2 TestContext (com.aire.ux.test.TestContext)2 ViewTest (com.aire.ux.test.ViewTest)2 Button (com.vaadin.flow.component.button.Button)2 lombok.val (lombok.val)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 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