-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…#6722) * fix: clear client-side selection when changing selection mode * replace IT with connector test Co-authored-by: Sascha Ißbrücker <[email protected]>
- Loading branch information
1 parent
ee21626
commit 5a3b0a1
Showing
2 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
75 changes: 75 additions & 0 deletions
75
...rent/vaadin-grid-flow-integration-tests/test/grid-connector-change-selection-mode.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { expect, fixtureSync, nextFrame } from '@open-wc/testing'; | ||
import { init, getBodyCellContent, setRootItems, initSelectionColumn } from './shared.js'; | ||
import type { FlowGrid } from './shared.js'; | ||
|
||
describe('grid connector - change selection mode', () => { | ||
let grid: FlowGrid; | ||
|
||
function clickSelectCheckbox(row: number) { | ||
getBodyCellContent(grid, row, 0)!.querySelector('vaadin-checkbox')!.click(); | ||
} | ||
|
||
beforeEach(async () => { | ||
grid = fixtureSync(` | ||
<vaadin-grid> | ||
<vaadin-grid-flow-selection-column></vaadin-grid-flow-selection-column> | ||
<vaadin-grid-column path="name"></vaadin-grid-column> | ||
</vaadin-grid> | ||
`); | ||
|
||
init(grid); | ||
|
||
const selectionColumn = grid.querySelector('vaadin-grid-flow-selection-column')!; | ||
initSelectionColumn(grid, selectionColumn); | ||
|
||
setRootItems(grid.$connector, [ | ||
{ key: '0', name: 'foo' }, | ||
{ key: '1', name: 'bar' } | ||
]); | ||
await nextFrame(); | ||
}); | ||
|
||
describe('clear selection', () => { | ||
it('should clear selection when changing from single to none', () => { | ||
grid.$connector.setSelectionMode('SINGLE'); | ||
getBodyCellContent(grid, 0, 0)!.click(); | ||
expect(grid.selectedItems.length).to.equal(1); | ||
|
||
grid.$connector.setSelectionMode('NONE'); | ||
|
||
expect(grid.selectedItems).to.be.empty; | ||
}); | ||
|
||
it('should clear selection when changing from single to multi ', () => { | ||
grid.$connector.setSelectionMode('SINGLE'); | ||
getBodyCellContent(grid, 0, 0)!.click(); | ||
expect(grid.selectedItems.length).to.equal(1); | ||
|
||
grid.$connector.setSelectionMode('MULTI'); | ||
|
||
expect(grid.selectedItems).to.be.empty; | ||
}); | ||
|
||
it('should clear selection when changing from multi to none', () => { | ||
grid.$connector.setSelectionMode('MULTI'); | ||
clickSelectCheckbox(0); | ||
clickSelectCheckbox(1); | ||
expect(grid.selectedItems.length).to.equal(2); | ||
|
||
grid.$connector.setSelectionMode('NONE'); | ||
|
||
expect(grid.selectedItems).to.be.empty; | ||
}); | ||
|
||
it('should clear selection when changing from multi to single', () => { | ||
grid.$connector.setSelectionMode('MULTI'); | ||
clickSelectCheckbox(0); | ||
clickSelectCheckbox(1); | ||
expect(grid.selectedItems.length).to.equal(2); | ||
|
||
grid.$connector.setSelectionMode('SINGLE'); | ||
|
||
expect(grid.selectedItems).to.be.empty; | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters