use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.
the class InMemoryFeatureManagerTest method ensureDisablingViewPreventsItFromBeingRegistered.
@ViewTest
void ensureDisablingViewPreventsItFromBeingRegistered(@Context TestContext $) {
val descriptor = new FeatureDescriptor("test.view.feature", "Test View Feature", ":application:modules:module-management:test-view", "Cool feature descriptor");
featureManager.registerFeature(descriptor);
assertTrue(featureManager.enable("test.view.feature"));
$.navigate(TestFeatureView.class);
$.flush();
var button = $.selectFirst("vaadin-button[text*=test]", Button.class);
assertTrue(button.isPresent());
featureManager.disable("test.view.feature");
$.navigate(MainView.class);
$.navigate(TestFeatureView.class);
button = $.selectFirst("vaadin-button[text*=test]", Button.class);
assertFalse(button.isPresent());
}
use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.
the class ApplicationLayoutTest method ensureRegisteringRouteWorks.
@ViewTest
@DirtiesContext
void ensureRegisteringRouteWorks(@Autowired ExtensionRegistry registry, @Context TestContext $) {
assertThrows(NotFoundException.class, () -> UI.getCurrent().navigate(MainNavigationComponent.class));
val reg = registry.register(RouteDefinition.global(MainNavigationComponent.class));
UI.getCurrent().navigate(MainNavigationComponent.class);
reg.remove();
assertThrows(NotFoundException.class, () -> UI.getCurrent().navigate(MainNavigationComponent.class));
}
use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.
the class ApplicationLayoutTest method ensureRegisteringSimpleComponentWorks.
@ViewTest
@DirtiesContext
void ensureRegisteringSimpleComponentWorks(@Autowired UserInterface ui, @Context TestContext $) {
val extension = new DefaultComponentExtension<>(":management-menu", (NavigationBar parent) -> {
val button = spy(new Button("Hello"));
parent.add(button);
});
var button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertFalse(button.isPresent());
val registration = ui.register(Selection.path(":main:navigation"), extension);
$.flush();
val menu = ui.selectFirst(Selection.path(":main:navigation:management-menu"));
assertNotNull(menu);
button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertTrue(button.isPresent());
registration.close();
$.flush(true);
assertEquals(0, ui.getExtensionRegistry().getExtensionCount());
button = $.selectFirst("vaadin-button[text~=Hello]", Button.class);
assertFalse(button.isPresent());
}
use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.
the class ApplicationLayoutTest method ensureRegistrationWorksWithComponents.
@ViewTest
@DirtiesContext
void ensureRegistrationWorksWithComponents(@Context TestContext $, @Autowired UserInterface userInterface) {
val registration = userInterface.register(Selection.path(":main-2:navbar"), Extensions.create(":sup", (@NonNull NavigationBar b) -> {
b.add(new Button("hello"));
}));
assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
val reg2 = userInterface.register(Mode.Global, MainNavigationComponent.class);
$.navigate(MainNavigationComponent.class);
assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isPresent());
registration.close();
$.navigate(MainView.class);
assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
$.navigate(MainNavigationComponent.class);
assertTrue($.selectFirst("vaadin-button[text=hello]", Button.class).isEmpty());
reg2.remove();
}
use of com.aire.ux.test.ViewTest in project aire-components by aire-ux.
the class ApplicationLayoutTest method ensureSelectionWorks.
@ViewTest
void ensureSelectionWorks(@Autowired UserInterface ui) {
val result = ui.selectFirst(Selection.path(":main:navigation", MainView.class));
assertTrue(result.isPresent());
assertInstanceOf(NavigationBar.class, result.get());
}
Aggregations