Skip to content

Commit 0d14b6e

Browse files
committed
fix: add tests
1 parent bb8b6a2 commit 0d14b6e

File tree

2 files changed

+36
-14
lines changed

2 files changed

+36
-14
lines changed

tests/suites/tenant/diagnostics/Diagnostics.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ export class Diagnostics {
243243
private memoryCard: Locator;
244244
private healthcheckCard: Locator;
245245
private tableRadioButton: Locator;
246+
private fixedHeightQueryElements: Locator;
247+
private copyLinkButton: Locator;
246248

247249
constructor(page: Page) {
248250
this.storage = new StoragePage(page);
@@ -259,6 +261,8 @@ export class Diagnostics {
259261
this.tableRadioButton = page.locator(
260262
'.ydb-table-with-controls-layout__controls .g-radio-button',
261263
);
264+
this.fixedHeightQueryElements = page.locator('.ydb-fixed-height-query');
265+
this.copyLinkButton = page.locator('.ydb-copy-link-button__icon');
262266

263267
// Info tab cards
264268
this.cpuCard = page.locator('.metrics-cards__tab:has-text("CPU")');
@@ -394,4 +398,29 @@ export class Diagnostics {
394398
.textContent();
395399
return selectedText?.trim() || '';
396400
}
401+
402+
async getFixedHeightQueryElementsCount(): Promise<number> {
403+
return await this.fixedHeightQueryElements.count();
404+
}
405+
406+
async getFixedHeightQueryElementHeight(index: number): Promise<string> {
407+
const element = this.fixedHeightQueryElements.nth(index);
408+
return await element.evaluate((el) => {
409+
return window.getComputedStyle(el).height;
410+
});
411+
}
412+
413+
async clickCopyLinkButton(): Promise<void> {
414+
await this.copyLinkButton.first().click();
415+
}
416+
417+
async isCopyLinkButtonVisible(): Promise<boolean> {
418+
return await this.copyLinkButton.first().isVisible();
419+
}
420+
421+
async isRowActive(rowIndex: number): Promise<boolean> {
422+
const rowElement = this.dataTable.locator(`tr.data-table__row:nth-child(${rowIndex})`);
423+
const rowElementClass = await rowElement.getAttribute('class');
424+
return rowElementClass?.includes('kv-top-queries__row_active') || false;
425+
}
397426
}

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -236,17 +236,13 @@ test.describe('Diagnostics Queries tab', async () => {
236236
await expect(diagnostics.table.isVisible()).resolves.toBe(true);
237237

238238
// Check that FixedHeightQuery components have the expected fixed height
239-
const fixedHeightElements = page.locator('.ydb-fixed-height-query');
240-
const elementCount = await fixedHeightElements.count();
239+
const rowCount = await diagnostics.table.getRowCount();
241240

242-
if (elementCount > 1) {
241+
if (rowCount > 1) {
243242
// Check that all FixedHeightQuery components have the same height
244243
const heights = [];
245-
for (let i = 0; i < Math.min(elementCount, 5); i++) {
246-
const element = fixedHeightElements.nth(i);
247-
const height = await element.evaluate((el) => {
248-
return window.getComputedStyle(el).height;
249-
});
244+
for (let i = 0; i < Math.min(rowCount, 5); i++) {
245+
const height = await diagnostics.getFixedHeightQueryElementHeight(i);
250246
heights.push(height);
251247
}
252248

@@ -298,9 +294,8 @@ test.describe('Diagnostics Queries tab', async () => {
298294
await page.waitForTimeout(500);
299295

300296
// Find and click the copy link button in the drawer
301-
const copyLinkButton = page.locator('.ydb-copy-link-button__icon').first();
302-
await expect(copyLinkButton).toBeVisible();
303-
await copyLinkButton.click();
297+
await expect(diagnostics.isCopyLinkButtonVisible()).resolves.toBe(true);
298+
await diagnostics.clickCopyLinkButton();
304299

305300
// Get the copied URL from clipboard
306301
const clipboardText = await page.evaluate(() => navigator.clipboard.readText());
@@ -313,11 +308,9 @@ test.describe('Diagnostics Queries tab', async () => {
313308

314309
const firstVisibleRowIndex = 4;
315310
// Verify the row is highlighted/selected (if applicable)
316-
const rowElement = page.locator(`tr.data-table__row:nth-child(${firstVisibleRowIndex})`);
317-
const rowElementClass = await rowElement.getAttribute('class');
318311
await page.waitForTimeout(1000);
319312

320-
const hasActiveClass = rowElementClass?.includes('kv-top-queries__row_active');
313+
const hasActiveClass = await diagnostics.isRowActive(firstVisibleRowIndex);
321314

322315
expect(hasActiveClass).toBe(true);
323316
});

0 commit comments

Comments
 (0)