mvysny / karibu-testing

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

GridKt._clickItem does not trigger SelectionListener #96

Closed simasch closed 2 years ago

simasch commented 2 years ago

I have a grid with a SelectionListener

grid.addSelectionListener(event -> event.getFirstSelectedItem()
        .ifPresent(seriesRecord -> UI.getCurrent().navigate(SeriesView.class, "" + seriesRecord.getId())));

Now I try to test this

GridKt._clickItem(seriesGrid, 0);

But the event is not triggered.

mvysny commented 2 years ago

The docs for _clickItem() mention that only the ItemClickEvent event is fired.

However, if the Grid itself fires a SelectionEvent along with ItemClickEvent upon item clicking, then it would make sense for Karibu-Testing to do the same. Can you please verify that Grid (in single select mode) fires both events?

simasch commented 2 years ago

Yes the Grid fires a SelectionEvent and a ItemClickEvent.

I often use the SelectionListener because the code in the listener should also run when I programmatically select an item

mvysny commented 2 years ago

You're right! I can observe the selection events fired before item click events (at least on Vaadin 21.0.9). However, this really depends on the selection mode: