vaadin / vaadin/browserless-test

Grid ItemDetailsRenderer not triggered (itemConsumer of ComponentRenderer not called)

Open
#29 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1
Forks
3
Avg merge
1d 20h
Merged PRs (30d)
51

Description

Problem

I want to test my Grid component with Browserless Tests. I configured an ItemDetailsRenderer that should open on click. Manually clicking a row opens the details, but when I click the row (or a column) in a Browserless Test the details do not open.

More context I already posted in the Vaadin forum: https://vaadin.com/forum/t/browserless-test-grid-itemdetailsrenderer/179401

Setup

In the Grid I use:

grid.setItemDetailsRenderer(
    new ComponentRenderer<>(() -> new MyItemDetailsComponent(someService, someOtherService),
                            MyItemDetailsComponent::setItem));
grid.setDetailsVisibleOnClick(true);

This opens the details for the selected row when I click the row manually.

Goal

I want to verify with a Browserless Test that the details open when a user clicks a row.

@Test
void testGrid_withOneEntity_shouldOpenDetailsOnClick() {
    final GridView gridView = navigate(GridView.class);
    Grid<Item> grid = $(Grid.class, gridView).single(); // grid is private in the view
    GridTester<Grid<Item>, Item> gridTest = test(grid);

    assertThat(gridTest.size()).isEqualTo(1); // one entry present
    assertThat(grid.isDetailsVisibleOnClick()).isTrue(); // setting is present

    gridTest.clickRow(0); // does not open details

    // try clicking a column
    Grid.Column<Item> column = grid.getColumns().get(0); // any column
    ComponentTester<Grid.Column<Item>> columnTester = test(column);
    columnTester.click(); // does not open details
   
    assertThat(grid.isDetailsVisible(gridTest.getRow(0))).isTrue(); // always false

   grid.setDetailsVisible(entity, true);//then it would be true, but I had to do it myself

}

Test environment

Test class extends SpringBrowserlessTest.
Annotated with @DataJpaTest and some test properties.
Vaadin 25.1, Spring Boot starter parent 4.0.4.

I import the item details component and nested dependencies in the test class using:
@Import(MyItemDetailsComponent.class, OtherNestedClass.class)

The MyItemDetailsComponent constructor is invoked in the test and its fields are set correctly, but MyItemDetailsComponent::setItem is never called and the logic executed when details open is not triggered.

Observed behavior

MyItemDetailsComponent constructor runs in the test.
setItem (the renderer’s item setter) is never called.
Grid.isDetailsVisible(...) remains false after clicks. (it returns only true when I explicitly set it to true using `grid.setDetailsVisible(entity, true);`

Question

Why does the ItemDetailsRenderer not get invoked in the Browserless Test (itemConsumer of ComponentRenderer not called), and how can I reliably open and assert the details panel in a Browserless Test? I might test if a grid.addItemClickListener() works if I do the details in there - but I would call this a workaround then

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue in testGrid_withOneEntity_shouldOpenDetailsOnClick(), focusing on GridTester.clickRow(0), ComponentTester.click(), and the ItemDetailsRenderer item setter. Compare the Browserless Test behavior with the manual click path and verify completion by confirming that setItem is called and Grid.isDetailsVisible(...) becomes true after the simulated click.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
testing
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.