mvysny / karibu-testing

Vaadin Server-Side Browserless Containerless Unit Testing
Apache License 2.0
111 stars 14 forks source link

PreserveOnRefresh annotation is not handled correctly in tests #118

Closed willemv closed 2 years ago

willemv commented 2 years ago

When you have a view with the @PreserveOnRefresh annotation, the view should survive a page reload but be reparented to a new UI.

The real VaadinServlet handles this in its AbstractNavigationStateRenderer (see its isPreserveOnRefreshTarget method), but when you call karibu's MockPage#reload this code is not triggered.

mvysny commented 2 years ago

Hi Willem, thank you for letting me know. You're right, I've reproduced the bug. Now the question is, how to fix it :-D

mvysny commented 2 years ago

Vaadin actually tries to remember the previous instances of the navigation chain, but needs ExtendedClientDetails to do so. Karibu-Testing doesn't mock that part of Vaadin, the ui.getPage().retrieveExtendedClientDetails() never calls the closure and thus the preserve-on-refresh storage never gets initialized. Let me work on that.

mvysny commented 2 years ago

Added support for ExtendedClientDetails which also adds support for @PreserveOnRefresh. Proverbial two birds one stone ;)

Fix will be present in Karibu-Testing 1.3.17

willemv commented 2 years ago

Thanks @mvysny, everything is working now!