Skip to content

Commit 043851a

Browse files
committed
fix: test
1 parent 6d6cc2d commit 043851a

File tree

2 files changed

+55
-13
lines changed

2 files changed

+55
-13
lines changed

tests/suites/tenant/diagnostics/Diagnostics.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,29 @@ export class Diagnostics {
446446
return rowElementClass?.includes('kv-top-queries__row_active') || false;
447447
}
448448

449+
async waitForActiveRow(timeout = 10000): Promise<boolean> {
450+
try {
451+
await this.dataTable.locator('.kv-top-queries__row_active').waitFor({
452+
state: 'visible',
453+
timeout: timeout,
454+
});
455+
return true;
456+
} catch {
457+
return false;
458+
}
459+
}
460+
461+
async getActiveRowIndex(): Promise<number | null> {
462+
const rows = await this.dataTable.locator('tr.data-table__row').all();
463+
for (let i = 0; i < rows.length; i++) {
464+
const className = await rows[i].getAttribute('class');
465+
if (className?.includes('kv-top-queries__row_active')) {
466+
return i + 1; // Return 1-based index
467+
}
468+
}
469+
return null;
470+
}
471+
449472
async isOwnerCardVisible(): Promise<boolean> {
450473
await this.ownerCard.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
451474
return true;

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

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,20 @@ test.describe.only('Diagnostics Queries tab', async () => {
264264
const diagnostics = new Diagnostics(page);
265265
await expect(diagnostics.table.isVisible()).resolves.toBe(true);
266266

267-
// Get the number of rows and select a row that requires scrolling (should be 100 from mock)
268-
const rowCount = await diagnostics.table.getRowCount();
269-
expect(rowCount).toBe(8); // Verify we have the expected 100 rows from mock
267+
// Get the number of visible rows (should be around 8 due to virtualization)
268+
const visibleRowCount = await diagnostics.table.getRowCount();
269+
expect(visibleRowCount).toBeGreaterThan(0);
270+
expect(visibleRowCount).toBeLessThanOrEqual(10); // Due to virtualization
271+
272+
// Target a row that's visible (use row 5 or 6 to ensure it's in the viewport)
273+
const targetRowIndex = Math.min(5, visibleRowCount);
270274

271-
// Target a row further down that requires scrolling
272-
const targetRowIndex = 8;
275+
// Store the query hash of the target row to verify later
276+
const targetQueryHash = await diagnostics.table.getCellValueByHeader(
277+
targetRowIndex,
278+
'Query Hash',
279+
);
280+
expect(targetQueryHash).toBeTruthy();
273281

274282
// Click on the target row to open the drawer
275283
await diagnostics.table.clickRow(targetRowIndex);
@@ -281,21 +289,32 @@ test.describe.only('Diagnostics Queries tab', async () => {
281289
await expect(diagnostics.isCopyLinkButtonVisible()).resolves.toBe(true);
282290
await diagnostics.clickCopyLinkButton();
283291

292+
// Small wait for clipboard operation
293+
await page.waitForTimeout(200);
294+
284295
// Get the copied URL from clipboard
285296
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
286297
expect(clipboardText).toBeTruthy();
287298
expect(clipboardText).toContain('/tenant');
288299

289300
// Navigate to the copied URL
290301
await page.goto(clipboardText);
291-
await page.waitForTimeout(1000);
292302

293-
const firstVisibleRowIndex = 4;
294-
// Verify the row is highlighted/selected (if applicable)
295-
await page.waitForTimeout(1000);
296-
297-
const hasActiveClass = await diagnostics.isRowActive(firstVisibleRowIndex);
298-
299-
expect(hasActiveClass).toBe(true);
303+
// Wait for the active row to appear
304+
const hasActiveRow = await diagnostics.waitForActiveRow();
305+
expect(hasActiveRow).toBe(true);
306+
307+
// Get the index of the active row
308+
const activeRowIndex = await diagnostics.getActiveRowIndex();
309+
expect(activeRowIndex).not.toBeNull();
310+
311+
// Verify the active row has the same query hash as the one we selected
312+
if (activeRowIndex) {
313+
const activeRowQueryHash = await diagnostics.table.getCellValueByHeader(
314+
activeRowIndex,
315+
'Query Hash',
316+
);
317+
expect(activeRowQueryHash).toBe(targetQueryHash);
318+
}
300319
});
301320
});

0 commit comments

Comments
 (0)