Skip to content

Commit 8400fc8

Browse files
committed
fix: better e2e
1 parent e638eff commit 8400fc8

File tree

2 files changed

+44
-1
lines changed

2 files changed

+44
-1
lines changed

tests/suites/tenant/diagnostics/Diagnostics.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,47 @@ export class Table {
6464

6565
return true;
6666
}
67+
68+
async getHeaders() {
69+
const headers = this.table.locator('th.data-table__th');
70+
const headerCount = await headers.count();
71+
const headerNames = [];
72+
for (let i = 0; i < headerCount; i++) {
73+
headerNames.push(await headers.nth(i).innerText());
74+
}
75+
return headerNames;
76+
}
77+
78+
async getCellValueByHeader(row: number, header: string) {
79+
const headers = await this.getHeaders();
80+
const colIndex = headers.indexOf(header);
81+
if (colIndex === -1) {
82+
throw new Error(`Header "${header}" not found`);
83+
}
84+
const cell = this.table.locator(
85+
`tr.data-table__row:nth-child(${row}) td:nth-child(${colIndex + 1})`,
86+
);
87+
return cell.innerText();
88+
}
89+
90+
async waitForCellValueByHeader(row: number, header: string, value: string) {
91+
const headers = await this.getHeaders();
92+
const colIndex = headers.indexOf(header);
93+
if (colIndex === -1) {
94+
throw new Error(`Header "${header}" not found`);
95+
}
96+
const cell = this.table.locator(
97+
`tr.data-table__row:nth-child(${row}) td:nth-child(${colIndex + 1})`,
98+
);
99+
await retryAction(async () => {
100+
const cellValue = (await cell.innerText()).trim();
101+
if (cellValue === value) {
102+
return true;
103+
}
104+
throw new Error(`Cell value ${cellValue} did not match expected ${value}`);
105+
});
106+
return true;
107+
}
67108
}
68109

69110
export enum QueriesSwitch {

tests/suites/tenant/diagnostics/diagnostics.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ test.describe('Diagnostics tab', async () => {
6666
await diagnostics.clickTab(DiagnosticsTab.Queries);
6767
await diagnostics.clickRadioSwitch(QueriesSwitch.Running);
6868
expect(await diagnostics.table.getRowCount()).toBe(1);
69-
expect(await diagnostics.table.waitForCellValue(1, 1, '–')).toBe(true);
69+
expect(
70+
await diagnostics.table.waitForCellValueByHeader(1, 'QueryText', longRunningQuery),
71+
).toBe(true);
7072
});
7173
});

0 commit comments

Comments
 (0)