Closed mvysny closed 2 years ago
Maybe overriding TestingLifecycleHook.getAllChildren()
and providing access to specific child components per PolymerTemplate implementor would be the key to solution.
Yup, that's the key. The solution is like this (Java):
public class MyLifecycleHook implements TestingLifecycleHook {
@Override
public void awaitAfterLookup() {
TestingLifecycleHook.Companion.getDefault().awaitAfterLookup();
}
@Override
public void awaitBeforeLookup() {
TestingLifecycleHook.Companion.getDefault().awaitBeforeLookup();
}
@NotNull
@Override
public List<Component> getAllChildren(@NotNull Component component) {
if (component instanceof BaseView) {
return Arrays.asList(((BaseView) component).main);
}
return TestingLifecycleHook.Companion.getDefault().getAllChildren(component);
}
}
To register this:
@BeforeAll
public static void configureKaribu() {
TestingLifecycleHookKt.setTestingLifecycleHook(new MyLifecycleHook());
}
A customer has a PolymerTemplate for the main app route, which nests individual routes inside. The routes are server-constructed and have proper state management (so they're not just "shells"); having access to the routes themselves would therefore be valuable.
Karibu-Testing should therefore expose an API which would allow the user to "override" children enumeration: it should be able to tell that a PolymerTemplate has particular children.