(page: E2EPage, options: GridSetupOptions)
| 25 | } |
| 26 | |
| 27 | export async function mountGrid(page: E2EPage, options: GridSetupOptions) { |
| 28 | const width = options.width ?? 900; |
| 29 | const height = options.height ?? 360; |
| 30 | const initialAttrs = [ |
| 31 | options.filter ? 'filter' : '', |
| 32 | options.exporting ? 'exporting' : '', |
| 33 | options.canMoveColumns ? 'can-move-columns' : '', |
| 34 | ] |
| 35 | .filter(Boolean) |
| 36 | .join(' '); |
| 37 | |
| 38 | await page.addInitScript(installBrowserGridHelpers); |
| 39 | await page.setContent(` |
| 40 | <div style="width:${width}px; height:${height}px;"> |
| 41 | <revo-grid ${initialAttrs} style="display:block; width:100%; height:100%;"></revo-grid> |
| 42 | </div> |
| 43 | `); |
| 44 | |
| 45 | await page.waitForSelector(SELECTORS.grid); |
| 46 | |
| 47 | await page.evaluate((config: GridSetupOptions) => { |
| 48 | const grid = document.querySelector<HTMLRevoGridElement>('revo-grid'); |
| 49 | if (!grid) throw new Error('Grid element was not created'); |
| 50 | const browserGlobals = globalThis as typeof globalThis & { __revoGridE2EHelpers?: BrowserGridHelpers }; |
| 51 | const helpers = browserGlobals.__revoGridE2EHelpers; |
| 52 | if (!helpers) throw new Error('Grid E2E helpers were not installed'); |
| 53 | |
| 54 | const { |
| 55 | columns, |
| 56 | source, |
| 57 | filter, |
| 58 | rowHeaders, |
| 59 | pinnedTopSource, |
| 60 | pinnedBottomSource, |
| 61 | range, |
| 62 | useClipboard, |
| 63 | resize, |
| 64 | readonly, |
| 65 | canMoveColumns, |
| 66 | grouping, |
| 67 | trimmedRows, |
| 68 | rtl, |
| 69 | theme, |
| 70 | exporting, |
| 71 | rowSize, |
| 72 | colSize, |
| 73 | } = config; |
| 74 | |
| 75 | function applyColumn(column: any): any { |
| 76 | const next = { ...column }; |
| 77 | if (next.__testId) { |
| 78 | next.columnProperties = helpers.toColumnProperties(next.__testId); |
| 79 | } |
| 80 | if (Array.isArray(next.children)) { |
| 81 | next.children = next.children.map(applyColumn); |
| 82 | } |
| 83 | return next; |
| 84 | } |
no outgoing calls
no test coverage detected