Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing of GridPro component #28

Closed
nbabb opened this issue Sep 25, 2019 · 5 comments
Closed

Testing of GridPro component #28

nbabb opened this issue Sep 25, 2019 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@nbabb
Copy link

nbabb commented Sep 25, 2019

Hi Martin,

We are evaluating GridPro and one of the things we're looking at is testing. GridPro allows cell editing through a double-click. I see in Grid.kt code for clicking a cell Renderer (i.e. _clickRenderer). I started to model an approach after what you have there.

By default the GridPro column renderer is ColumnPathRenderer (which doesn't supply a Component). I was thinking that once I get the component I could fire two click events. I'd prefer a solution where I don't have to change the default renderer of GridPro.

Will I need to use a ComponentRenderer and call createComponent and fire click events for this component in order to enter into edit mode for a cell? Suggestions appreciated.

Thanks

@mvysny
Copy link
Owner

mvysny commented Sep 25, 2019

Hi, hmm, it could be that GridPro listens for some double-click event which even bypasses the renderers altogether. Please let me take a look at the GridPro sources - perhaps there is an easier way to show the editor from the server-side.

If I understand correctly, the task is just to open an editor for a particular row, is that correct? Then we should be able to target individual editor components and click the "Save" button from server-side.

@mvysny mvysny self-assigned this Sep 25, 2019
@mvysny mvysny added enhancement New feature or request question Further information is requested labels Sep 25, 2019
@nbabb
Copy link
Author

nbabb commented Sep 25, 2019

Yes. The desired behavior would be to double-click to edit. Then change a value and close the editor (loss of focus) and commit the value to the component's model. Thanks for checking!

@nbabb
Copy link
Author

nbabb commented Sep 26, 2019

So this approach works, but not ideal. This is a snippet from a working test, to convey the idea.

        GridPro grid = (GridPro) gridWrapper.root
        JreJsonObject jsonObject = new JreJsonObject();
        jsonObject.set("key", new JreJsonString("1"))
        jsonObject.set("col2", new JreJsonString("some changed value"))

//        ComponentUtil.fireEvent(grid, new GridPro.CellEditStartedEvent<BeanItem>(grid, false, jsonObject, "col2"))
        ComponentUtil.fireEvent(grid, new GridPro.ItemPropertyChangedEvent<BeanItem>(grid, false, jsonObject, "col2"))
        gridWrapper.getListedItems().collect { it.stringField } == ["some changed value"]

@mvysny
Copy link
Owner

mvysny commented Sep 26, 2019

Thank you. Initial work has been done in 74f06db but we need to also support invoking of the ItemUpdaters for individual columns, to also test those. Right now I'm thinking about simply adding extension property to Grid.Column such as column._gridPro._checkbox(true) or something along those lines, but please feel free to suggest alternative API.

@mvysny mvysny removed the question Further information is requested label Sep 27, 2019
mvysny added a commit that referenced this issue Sep 27, 2019
mvysny added a commit that referenced this issue Sep 27, 2019
@mvysny
Copy link
Owner

mvysny commented Sep 27, 2019

The support for mocking inline Grid Pro editor has been added; please see the readme on how to use it: https://github.com/mvysny/karibu-testing/tree/master/karibu-testing-v10

Just let me know if there is something more needed for a proper GridPro testing.

@mvysny mvysny closed this as completed Sep 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants