(page: Page)
| 234 | }); |
| 235 | |
| 236 | async function getGridState(page: Page) { |
| 237 | return page.evaluate(() => { |
| 238 | const grid = document.querySelector<HTMLElement>('[role="grid"]')!; |
| 239 | const gridRect = grid.getBoundingClientRect(); |
| 240 | const viewRight = document.documentElement.clientWidth; |
| 241 | const viewBottom = document.documentElement.clientHeight; |
| 242 | |
| 243 | // Region of the grid's client area that is visible within the viewport |
| 244 | const left = Math.max(gridRect.left + grid.clientLeft, 0); |
| 245 | const right = Math.min( |
| 246 | gridRect.left + grid.clientLeft + grid.clientWidth, |
| 247 | viewRight |
| 248 | ); |
| 249 | const top = Math.max(gridRect.top + grid.clientTop, 0); |
| 250 | const bottom = Math.min( |
| 251 | gridRect.top + grid.clientTop + grid.clientHeight, |
| 252 | viewBottom |
| 253 | ); |
| 254 | |
| 255 | const cells = Array.from(grid.querySelectorAll<HTMLElement>("[data-row]")); |
| 256 | const rects = cells.map((cell) => cell.getBoundingClientRect()); |
| 257 | |
| 258 | // Sample points within the visible region; each must be covered by a rendered cell |
| 259 | let uncovered = 0; |
| 260 | if (right > left && bottom > top) { |
| 261 | for (let x = left + 1; x < right; x += 37) { |
| 262 | for (let y = top + 1; y < bottom; y += 13) { |
| 263 | if ( |
| 264 | !rects.some( |
| 265 | (rect) => |
| 266 | x >= rect.left && |
| 267 | x <= rect.right && |
| 268 | y >= rect.top && |
| 269 | y <= rect.bottom |
| 270 | ) |
| 271 | ) { |
| 272 | uncovered++; |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | return { |
| 279 | gridScrollsHorizontally: grid.scrollWidth > grid.clientWidth, |
| 280 | gridScrollsVertically: grid.scrollHeight > grid.clientHeight, |
| 281 | pageScrollsHorizontally: |
| 282 | document.documentElement.scrollWidth > |
| 283 | document.documentElement.clientWidth, |
| 284 | renderedCells: cells.length, |
| 285 | uncovered |
| 286 | }; |
| 287 | }); |
| 288 | } |
| 289 | |
| 290 | test.describe("Grid with window scrollElement", () => { |
| 291 | test("rows scroll with the page and columns scroll within the grid", async ({ |
no outgoing calls
no test coverage detected