testbench icon indicating copy to clipboard operation
testbench copied to clipboard

Add helper for navigation with query parameters in UI Unit Test

Open mcollovati opened this issue 2 years ago • 3 comments

This PR improved the UI class by adding navigation methods that take query parameters. UI Unit Test base class should also provide such helpers.

mcollovati avatar Feb 25 '24 18:02 mcollovati

@mcollovati Do you have any appropriate workaround to perform a test with navigating to a view with query parameters? Just don't test such things as public <T extends Component> T navigate(String location, Class<T> expectedTarget); does not allow query parameters in the location-String 😉?

ma99koch avatar Jan 13 '25 16:01 ma99koch

As a workaround, I think you can directly use UI.getCurrent().navigate(Class<? extends T> navigationTarget, QueryParameters queryParameters). It should work, but you will lose the checks on UI and target view.

To also have the checks, you can create your own navigate(...) method and use reflection to call verifyAndGetUI and validateNavigationTarget.

mcollovati avatar Jan 13 '25 17:01 mcollovati

Thanks, this worked! Somehow didn't had in mind I can just use UI.getCurrent.navigate()...

ma99koch avatar Jan 13 '25 17:01 ma99koch