Skip to content

Commit 4b1889f

Browse files
fix: memory tests (#1699)
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent f164489 commit 4b1889f

File tree

3 files changed

+75
-3
lines changed

3 files changed

+75
-3
lines changed

tests/suites/memoryViewer/MemoryViewer.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type {Locator, Page} from '@playwright/test';
22

3+
import {VISIBILITY_TIMEOUT} from '../tenant/TenantPage';
4+
35
export class MemoryViewer {
46
readonly container: Locator;
57
readonly progressContainer: Locator;
@@ -24,6 +26,14 @@ export class MemoryViewer {
2426
this.definitionList = this.popup.locator('.g-definition-list');
2527
}
2628

29+
async isVisible() {
30+
return this.container.isVisible();
31+
}
32+
33+
async waitForVisible() {
34+
await this.container.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
35+
}
36+
2737
async getStatus() {
2838
const classList = await this.container.getAttribute('class');
2939
if (classList?.includes('memory-viewer_status_good')) {

tests/suites/memoryViewer/memoryViewer.test.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import {expect, test} from '@playwright/test';
22

33
import {NodesPage} from '../nodes/NodesPage';
4+
import {PaginatedTable} from '../paginatedTable/paginatedTable';
45

56
import {MemoryViewer} from './MemoryViewer';
67

78
test.describe('Memory Viewer Widget', () => {
89
test.beforeEach(async ({page}) => {
910
const nodesPage = new NodesPage(page);
11+
const memoryViewer = new MemoryViewer(page);
1012
await nodesPage.goto();
1113

12-
// Get the first row's memory viewer
13-
const paginatedTable = await page.locator('.ydb-paginated-table__table');
14-
await paginatedTable.waitFor();
14+
const paginatedTable = new PaginatedTable(page);
15+
await paginatedTable.waitForTableVisible();
16+
await paginatedTable.waitForTableData();
17+
if (!(await memoryViewer.isVisible())) {
18+
await paginatedTable.openColumnSetup();
19+
await paginatedTable.setColumnChecked('Memory');
20+
await paginatedTable.applyColumnVisibility();
21+
}
22+
await memoryViewer.waitForVisible();
1523
});
1624

1725
test('Memory viewer is visible and has correct status', async ({page}) => {

tests/suites/paginatedTable/paginatedTable.ts

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type {Locator, Page} from '@playwright/test';
22

3+
import {VISIBILITY_TIMEOUT} from '../tenant/TenantPage';
4+
35
export class PaginatedTable {
46
private page: Page;
57
private tableSelector: Locator;
@@ -11,6 +13,8 @@ export class PaginatedTable {
1113
private refreshButton: Locator;
1214
private refreshIntervalSelect: Locator;
1315
private headCells: Locator;
16+
private columnSetupButton: Locator;
17+
private columnSetupPopup: Locator;
1418

1519
constructor(page: Page) {
1620
this.page = page;
@@ -23,6 +27,14 @@ export class PaginatedTable {
2327
this.emptyTableRows = this.tableSelector.locator('.ydb-paginated-table__row_empty');
2428
this.refreshButton = page.locator('.auto-refresh-control button[aria-label="Refresh"]');
2529
this.refreshIntervalSelect = page.getByTestId('ydb-autorefresh-select');
30+
this.columnSetupButton = this.tableSelector.locator(
31+
'.g-tree-select.g-table-column-setup button',
32+
);
33+
this.columnSetupPopup = page.locator('.g-popup .g-select-popup.g-tree-select__popup');
34+
}
35+
36+
async waitForTableVisible() {
37+
await this.tableSelector.waitFor({state: 'visible', timeout: VISIBILITY_TIMEOUT});
2638
}
2739

2840
async search(searchTerm: string) {
@@ -119,6 +131,48 @@ export class PaginatedTable {
119131
await this.waitForTableData();
120132
}
121133

134+
async openColumnSetup() {
135+
await this.columnSetupButton.click();
136+
await this.columnSetupPopup.waitFor({state: 'visible'});
137+
}
138+
139+
async setColumnChecked(columnName: string) {
140+
const columnOption = this.columnSetupPopup.locator(`[data-list-item="${columnName}"]`);
141+
const checkIcon = columnOption.locator('.g-icon.g-color-text_color_info');
142+
const isVisible = await checkIcon.isVisible();
143+
if (!isVisible) {
144+
await columnOption.click();
145+
}
146+
}
147+
148+
async setColumnUnchecked(columnName: string) {
149+
const columnOption = this.columnSetupPopup.locator(`[data-list-item="${columnName}"]`);
150+
const checkIcon = columnOption.locator('.g-icon.g-color-text_color_info');
151+
const isVisible = await checkIcon.isVisible();
152+
if (isVisible) {
153+
await columnOption.click();
154+
}
155+
}
156+
157+
async applyColumnVisibility() {
158+
const applyButton = this.columnSetupPopup.locator('button:has-text("Apply")');
159+
await applyButton.click();
160+
await this.columnSetupPopup.waitFor({state: 'hidden'});
161+
}
162+
163+
async getVisibleColumnsCount(): Promise<string> {
164+
const statusText = await this.columnSetupButton
165+
.locator('.g-table-column-setup__status')
166+
.innerText();
167+
return statusText;
168+
}
169+
170+
async isColumnVisible(columnName: string): Promise<boolean> {
171+
const columnOption = this.columnSetupPopup.locator(`[data-list-item="${columnName}"]`);
172+
const checkIcon = columnOption.locator('.g-icon.g-color-text_color_info');
173+
return await checkIcon.isVisible();
174+
}
175+
122176
private async getColumnIndex(columnName: string): Promise<number> {
123177
const count = await this.headCells.count();
124178
for (let i = 0; i < count; i++) {

0 commit comments

Comments
 (0)