@@ -4,7 +4,7 @@ import { commands, page, userEvent } from '@vitest/browser/context';
4
4
5
5
import { DataGrid } from '../../../src' ;
6
6
import type { Column , DataGridProps } from '../../../src' ;
7
- import { getCell , getCellsAtRowIndex , getGrid , getSelectedCell , scrollGrid } from '../utils' ;
7
+ import { getCell , getCellsAtRowIndex , getGrid , getSelectedCell } from '../utils' ;
8
8
9
9
interface Row {
10
10
col1 : number ;
@@ -94,15 +94,19 @@ describe('Editor', () => {
94
94
95
95
page . render ( < EditorTest gridRows = { rows } /> ) ;
96
96
await userEvent . click ( getCellsAtRowIndex ( 0 ) [ 0 ] ) ;
97
- expect ( getCellsAtRowIndex ( 0 ) ) . toHaveLength ( 2 ) ;
98
- await scrollGrid ( { scrollTop : 2000 } ) ;
99
- expect ( getCellsAtRowIndex ( 0 ) ) . toHaveLength ( 1 ) ;
97
+ const selectedRowCells = page
98
+ . getByRole ( 'row' )
99
+ . filter ( { has : getSelectedCell ( ) } )
100
+ . getByRole ( 'gridcell' ) ;
101
+ await expect . poll ( ( ) => selectedRowCells . elements ( ) . length ) . toBe ( 2 ) ;
102
+ await commands . scrollGrid ( { scrollTop : 2000 } ) ;
103
+ await expect . poll ( ( ) => selectedRowCells . elements ( ) . length ) . toBe ( 1 ) ;
100
104
const editor = page . getByRole ( 'spinbutton' , { name : 'col1-editor' } ) ;
101
105
await expect . element ( editor ) . not . toBeInTheDocument ( ) ;
102
106
expect ( getGrid ( ) . element ( ) . scrollTop ) . toBe ( 2000 ) ;
103
107
// TODO: await userEvent.keyboard('123'); fails in FF
104
108
await userEvent . keyboard ( '{enter}123' ) ;
105
- expect ( getCellsAtRowIndex ( 0 ) ) . toHaveLength ( 2 ) ;
109
+ await expect . poll ( ( ) => selectedRowCells . elements ( ) . length ) . toBe ( 2 ) ;
106
110
await expect . element ( editor ) . toHaveValue ( 123 ) ;
107
111
expect ( getGrid ( ) . element ( ) . scrollTop ) . toBe ( 0 ) ;
108
112
} ) ;
0 commit comments