Skip to content

Add Grid editor support to GridTester #262

Description

@totally-not-ai

Problem. The Grid row editor (Grid.getEditor()) has no tester support. A
test can open a view that uses the editor, but there is no way to drive it:

var grid = new GridTester<>(component);
grid.doubleClickRow(0);   // the app's listener may open the editor...
// ...and from here there is nothing: no isEditorOpen(), no way to reach the
// editor's fields, no saveEditor() / cancelEditor()

So the whole "user double-clicks a row, edits the fields, saves (or cancels),
the row shows the new values" flow — the reason the editor exists — cannot be
expressed.

What exists today

  • GridProTester.setValue(row, column, value) covers GridPro's inline
    editing. That is a different component with a different interaction model and
    does not help with the plain Grid editor.
  • The Kotlin layer has Editor<T>._editItem(item) in
    shared/src/main/kotlin/com/vaadin/browserless/component/Grid.kt, which calls
    editItem(item) and then does a client round trip. Nothing calls it and no
    tester exposes it, so it is unreachable from a test as things stand.
  • doubleClickRow(row) already fires ItemDoubleClickEvent, so an application
    that wires addItemDoubleClickListener to editor.editItem(...) does get the
    editor opened today. The gap is everything after that point.

Sketch of the missing API on GridTester:

  • editRow(int row) — open the editor for a row
  • isEditorOpen() and the item currently being edited
  • getEditorComponent(int column) / getEditorComponent(String columnKey)
    the live field component of the open editor
  • saveEditor() / cancelEditor()

Points that need deciding before implementing

  • Grid.Column.getEditorComponent() only returns the statically set component.
    When a column uses setEditorComponent(SerializableFunction<T, Component>)
    the component is produced per item, so the tester has to hand back the
    instance actually bound for the edited item — the same problem
    getCellComponent already solves for renderers.
  • Buffered vs unbuffered editors behave differently on save, so what
    saveEditor() means in each mode has to be pinned down.
  • A save can be refused by editor.getBinder() validation. The failed
    validation path is exactly what tests want to assert, so it should surface as
    something assertable rather than a silently ignored save.
  • Following the convention used by the rest of the testers ("fail if the user
    could not have done this"), editRow should presumably fail when the grid has
    no editor binder, and interacting with a closed editor should fail rather than
    silently do nothing.

Split out of #175, whose deselect part shipped in #187.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions