Skip to content

Commit 8153fcf

Browse files
tests: add tests for groups
1 parent 23d4212 commit 8153fcf

File tree

4 files changed

+59
-10
lines changed

4 files changed

+59
-10
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@
7676
"typecheck": "tsc --noEmit",
7777
"prepare": "husky",
7878
"test:e2e:install": "npx playwright install --with-deps",
79-
"test:e2e": "npx playwright test --config=playwright.config.ts"
79+
"test:e2e": "npx playwright test --config=playwright.config.ts",
80+
"test:e2e:local": "PLAYWRIGHT_BASE_URL=http://localhost:3000/ npm run test:e2e"
8081
},
8182
"lint-staged": {
8283
"*.{scss, css}": [

src/containers/Nodes/NodesControls/NodesControls.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {useViewerNodesHandlerHasGroupingBySystemState} from '../../../store/redu
1111
import {useProblemFilter} from '../../../store/reducers/settings/hooks';
1212
import {getNodesGroupByOptions} from '../columns/constants';
1313
import i18n from '../i18n';
14+
import {b} from '../shared';
1415
import {useNodesPageQueryParams} from '../useNodesPageQueryParams';
1516

1617
interface NodesControlsProps {
@@ -83,6 +84,8 @@ export function NodesControls({
8384
defaultValue={groupByParam ? [groupByParam] : undefined}
8485
onUpdate={handleGroupBySelectUpdate}
8586
options={groupByoptions}
87+
className={b('group-by-select')}
88+
popupClassName={b('group-by-popup')}
8689
/>
8790
</React.Fragment>
8891
) : null}

tests/suites/nodes/NodesPage.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,53 @@ import type {Locator, Page} from '@playwright/test';
33
import {PageModel} from '../../models/PageModel';
44
import {nodesPage} from '../../utils/constants';
55

6+
type NodesGroupByOptions =
7+
| 'Host'
8+
| 'DC'
9+
| 'Rack'
10+
| 'Database'
11+
| 'Version'
12+
| 'Uptime'
13+
| 'Missing'
14+
| 'DiskSpaceUsage';
15+
616
export class NodesPage extends PageModel {
717
readonly table: Locator;
818

19+
private groupBySelect: Locator;
20+
private groupByPopup: Locator;
21+
22+
private tableGroupsWrapper: Locator;
23+
924
constructor(page: Page) {
1025
super(page, nodesPage);
1126

1227
this.table = this.selector.locator('.ydb-paginated-table__table');
28+
29+
this.groupBySelect = this.page.locator('.ydb-nodes__group-by-select');
30+
this.groupByPopup = this.page.locator('.ydb-nodes__group-by-popup');
31+
32+
this.tableGroupsWrapper = this.page.locator('.ydb-nodes__groups-wrapper');
33+
}
34+
35+
async selectGroupByOption(option: NodesGroupByOptions) {
36+
await this.groupBySelect.click();
37+
await this.groupByPopup.isVisible();
38+
await this.groupByPopup.locator('.g-select-list__option').getByText(option).click();
39+
}
40+
async waitForTableGroupsLoaded() {
41+
await this.page.locator('.table-skeleton').isHidden();
42+
await this.tableGroupsWrapper.isVisible();
43+
}
44+
selectTableGroup(name: string) {
45+
return this.tableGroupsWrapper.locator('.ydb-table-group').filter({hasText: name}).first();
46+
}
47+
async expandTableGroup(name: string) {
48+
await this.selectTableGroup(name).getByRole('button').click();
49+
}
50+
selectTableGroupContent(name: string) {
51+
return this.selectTableGroup(name)
52+
.locator('.ydb-table-group__content')
53+
.locator('.ydb-paginated-table');
1354
}
1455
}

tests/suites/nodes/nodes.test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,19 +61,23 @@ test.describe('Test Nodes Paginated Table', async () => {
6161
expect(filteredRowCount).toBeLessThanOrEqual(initialRowCount);
6262
});
6363

64-
test('Radio button selection changes displayed data', async ({page}) => {
65-
const paginatedTable = new PaginatedTable(page);
64+
test('Table groups displayed correctly if group by option is selected', async ({page}) => {
65+
const nodesPage = new NodesPage(page);
66+
const nodesTable = new PaginatedTable(page);
6667

67-
await paginatedTable.waitForTableToLoad();
68-
await paginatedTable.waitForTableData();
68+
await nodesTable.waitForTableToLoad();
69+
await nodesTable.waitForTableData();
6970

70-
const initialRowCount = await paginatedTable.getRowCount();
71-
await paginatedTable.selectRadioOption(0, 'With problems');
71+
const rowData = await nodesTable.getRowData(0);
72+
const host = rowData['Host'];
7273

73-
await page.waitForTimeout(1000); // Wait for the table to update
74+
await nodesPage.selectGroupByOption('Host');
75+
await nodesPage.waitForTableGroupsLoaded();
7476

75-
const filteredRowCount = await paginatedTable.getRowCount();
76-
expect(filteredRowCount).toBeLessThanOrEqual(initialRowCount);
77+
await nodesPage.selectTableGroup(host).isVisible();
78+
79+
await nodesPage.expandTableGroup(host);
80+
await nodesPage.selectTableGroupContent(host).isVisible();
7781
});
7882

7983
test('Node count is displayed correctly', async ({page}) => {

0 commit comments

Comments
 (0)