Closed satorstefan closed 1 year ago
Hi, thank you for letting me know!
Perhaps something like assertFalse(GridKt._getColumnByKey(key).isVisible())
would work equally well - it would provide a proper error message if the column with such a key doesn't exist.
Basically, I'm trying to avoid the API duplication. For example, if we would to have assertColumnNotVisible(String key)
, then we should also have assertColumnSortable()
, assertColumnIsFrozen()
, assertColumnIsNotFrozen(String key)
and a function for every Grid.Column
property, which looks like a lot of existing API duplication.
I propose to instead document the assertColumnNotVisible()
solution in the README. Would that work for you?
Documentation added: https://github.com/mvysny/karibu-testing/tree/master/karibu-testing-v10#grid-columns - please let me know whether this works for you.
Hello Martin,
assertFalse(GridKt._getColumnByKey(getGrid(), "delete").isVisible());
but this results in an AssertionError: java.lang.AssertionError: Grid[dataprovider='CallbackDataProvider', @multi-sort-priority='prepend', @theme='no-row-borders compact no-border column-dividers second-grid-theme']: No such column with key 'delete'; available columns: [name, typ, factor, changedAt]
Also I think there is a typo in the documentation now. This is not the right code snippet: assertFalse(GridKt._getColumnByKey(grid, "delete"));
This seems to work:
assertThrows(AssertionError.class, () -> {
GridKt._getColumnByKey(getGrid(), "delete");
});
You need to replace "delete" with the appropriate key of your Grid's Column.
GridKt._getColumnByKey(getGrid(), SafeguardTable.COLUMN_ACTION);
also leads to:
java.lang.AssertionError: Grid[dataprovider='CallbackDataProvider', @multi-sort-priority='prepend', @theme='no-row-borders compact no-border column-dividers second-grid-theme']: No such column with key 'action'; available columns: [name, typ, factor, changedAt]
This works. So maybe you should update the documentation again?
assertThrows(AssertionError.class, () -> {
GridKt._getColumnByKey(getGrid(), SafeguardTable.COLUMN_ACTION);
});
Please try GridKt._getColumnByKey(getGrid(), "changedAt");
or some other column that exists on the grid.
That works, but I want to check that a column is NOT visible/available.
If you wish to assert that a column with given key doesn't exist, please use assertNull(grid.getColumnByKey(key))
.
I want to check that a user will not see some columns of a grid.
The columns have keys.
Maybe a methode like: assertColumnNotVisible(String key) would be helpful?