Files
grafana/e2e-playwright/panels-suite/table-utils.ts
Alex Spencer 6c9faa7595 TableNG: Footer enhancements (#102948)
* Table: Footer support for multiple reducers

* fix migrator test output due to required default value

* fix go migration test

* more go test fixes

* fix go tests for footer

* Merge #110062

* update migration dashboard

* Small docs fixes

* Small docs fix

* remove migration method in Go, update js unit test

* add migration dashboard for footer and clean up some issues with countAll

* Footer should always use og rows for calcs

* update footer to be unaffected by filtering and sorting

* more e2es

* add more complex footer to kitchen sink, migrate panel all the way up

* update codeowners for e2e

* relocate footer migration panels and e2es to main 12.2 migration dashboard

* go further with the migration; kill unused fields, rename reducer to reducers

* get the go code up to date, move enablePagination to its own option as well

* add a unit to one of the numeric columns with a footer in kitchen sink

* fix reducers override in kitchen sink migration table

---------

Co-authored-by: Paul Marbach <paul.marbach@grafana.com>
Co-authored-by: Isabel Matwawana <isabel.matwawana@grafana.com>
Co-authored-by: Isabel Matwawana <76437239+imatwawana@users.noreply.github.com>
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
2025-09-03 18:03:33 -04:00

32 lines
1.1 KiB
TypeScript

import { Page, Locator } from '@playwright/test';
export const getCell = async (loc: Page | Locator, rowIdx: number, colIdx: number) =>
loc
.getByRole('row')
.nth(rowIdx)
.getByRole(rowIdx === 0 ? 'columnheader' : 'gridcell')
.nth(colIdx);
export const getCellHeight = async (loc: Page | Locator, rowIdx: number, colIdx: number) => {
const cell = await getCell(loc, rowIdx, colIdx);
return (await cell.boundingBox())?.height ?? 0;
};
export const getColumnIdx = async (loc: Page | Locator, columnName: string) => {
// find the index of the column "Long text." The kitchen sink table will change over time, but
// we can just find the column programatically and use it throughout the test.
let result = -1;
const colCount = await loc.getByRole('columnheader').count();
for (let colIdx = 0; colIdx < colCount; colIdx++) {
const cell = await getCell(loc, 0, colIdx);
if ((await cell.textContent()) === columnName) {
result = colIdx;
break;
}
}
if (result === -1) {
throw new Error(`Could not find the "${columnName}" column in the table`);
}
return result;
};