@@ -2,7 +2,7 @@ import {expect, test} from '@playwright/test';
22
33import { NodesPage } from '../nodes/NodesPage' ;
44
5- import { setupNodesMock , setupSettingsMock } from './mocks' ;
5+ import { setupEmptyNodesMock , setupLargeNodesMock , setupNodesMock , setupSettingsMock } from './mocks' ;
66import { PaginatedTable } from './paginatedTable' ;
77
88test . describe ( 'PaginatedTable' , ( ) => {
@@ -29,17 +29,7 @@ test.describe('PaginatedTable', () => {
2929 expect ( firstRowData [ 'Host' ] ) . toBe ( 'host-0.test' ) ;
3030 expect ( firstRowData [ 'Version' ] ) . toBe ( 'main.b7cfb36' ) ;
3131
32- // Scroll to bottom of container
33- await page . evaluate ( ( ) => {
34- const container = document . querySelector ( '.ydb-cluster' ) ;
35- if ( container ) {
36- // Force scroll to bottom
37- container . scrollTo ( {
38- top : container . scrollHeight ,
39- behavior : 'instant' ,
40- } ) ;
41- }
42- } ) ;
32+ await paginatedTable . scrollToBottom ( ) ;
4333
4434 await paginatedTable . waitForTableData ( ) ;
4535
@@ -55,4 +45,104 @@ test.describe('PaginatedTable', () => {
5545 expect ( uptime ) . toMatch ( / ^ ( \d + d \s ) ? ( \d + ) : ( \d { 2 } ) : ( \d { 2 } ) $ / ) ; // Format: DDd? HH:MM:SS
5646 }
5747 } ) ;
48+
49+ test . only ( 'loads data when scrolling to middle of table' , async ( { page} ) => {
50+ // Setup mocks with large dataset
51+ await setupLargeNodesMock ( page ) ;
52+ await setupSettingsMock ( page ) ;
53+
54+ // Navigate to nodes page which uses PaginatedTable
55+ const nodesPage = new NodesPage ( page ) ;
56+ await nodesPage . goto ( ) ;
57+
58+ const paginatedTable = new PaginatedTable ( page ) ;
59+ await paginatedTable . waitForTableVisible ( ) ;
60+ await paginatedTable . waitForTableData ( ) ;
61+
62+ // Get initial row count
63+ const initialVisibleRows = await paginatedTable . getRowCount ( ) ;
64+ expect ( initialVisibleRows ) . toBeGreaterThan ( 0 ) ;
65+ expect ( initialVisibleRows ) . toBeLessThan ( 1000 ) ; // Should not show all rows initially
66+
67+ // Scroll to middle of container
68+ await paginatedTable . scrollToMiddle ( ) ;
69+ await paginatedTable . waitForTableData ( ) ;
70+
71+ // Get data from middle rows to verify middle chunk loaded
72+ const rowCount = await paginatedTable . getRowCount ( ) ;
73+ const middleRowIndex = Math . floor ( rowCount / 2 ) ;
74+ const middleRowData = await paginatedTable . getRowData ( middleRowIndex ) ;
75+ expect ( middleRowData [ 'Host' ] ) . toBe ( 'host-500.test' ) ;
76+ expect ( middleRowData [ 'Version' ] ) . toBe ( 'main.b7cfb36' ) ;
77+ } ) ;
78+
79+ test ( 'displays empty state when no data is present' , async ( { page} ) => {
80+ // Setup mocks with empty data
81+ await setupEmptyNodesMock ( page ) ;
82+ await setupSettingsMock ( page ) ;
83+
84+ const nodesPage = new NodesPage ( page ) ;
85+ await nodesPage . goto ( ) ;
86+
87+ const paginatedTable = new PaginatedTable ( page ) ;
88+ await paginatedTable . waitForTableVisible ( ) ;
89+
90+ // Verify empty state
91+ const rowCount = await paginatedTable . getRowCount ( ) ;
92+ expect ( rowCount ) . toBe ( 1 ) ;
93+ const emptyDataMessage = await paginatedTable . getEmptyDataMessageLocator ( ) ;
94+ await expect ( emptyDataMessage ) . toContainText ( 'No such nodes' ) ;
95+ } ) ;
96+
97+ test ( 'handles 10 pages of data correctly' , async ( { page} ) => {
98+ // Setup mocks with 1000 nodes (100 per page * 10 pages)
99+ await setupSettingsMock ( page ) ;
100+ await setupLargeNodesMock ( page ) ;
101+
102+ const nodesPage = new NodesPage ( page ) ;
103+ await nodesPage . goto ( ) ;
104+
105+ const paginatedTable = new PaginatedTable ( page ) ;
106+ await paginatedTable . waitForTableVisible ( ) ;
107+ await paginatedTable . waitForTableData ( ) ;
108+
109+ // Verify initial data load
110+ const initialRowCount = await paginatedTable . getRowCount ( ) ;
111+ expect ( initialRowCount ) . toBeGreaterThan ( 0 ) ;
112+ expect ( initialRowCount ) . toBeLessThan ( 1000 ) ; // Should not load all rows at once
113+
114+ await paginatedTable . scrollToBottom ( ) ;
115+ await paginatedTable . waitForTableData ( ) ;
116+
117+ // Verify we can load data from the last page
118+ const finalRowCount = await paginatedTable . getRowCount ( ) ;
119+ const lastRowData = await paginatedTable . getRowData ( finalRowCount - 1 ) ;
120+ expect ( lastRowData [ 'Host' ] ) . toBe ( 'host-999.test' ) ; // Last node in 1000 nodes (0-999)
121+ } ) ;
122+
123+ test ( 'handles 100 pages of data correctly' , async ( { page} ) => {
124+ // Setup mocks with 10000 nodes (100 per page * 10 pages)
125+ await setupSettingsMock ( page ) ;
126+ await setupLargeNodesMock ( page , 10000 ) ;
127+
128+ const nodesPage = new NodesPage ( page ) ;
129+ await nodesPage . goto ( ) ;
130+
131+ const paginatedTable = new PaginatedTable ( page ) ;
132+ await paginatedTable . waitForTableVisible ( ) ;
133+ await paginatedTable . waitForTableData ( ) ;
134+
135+ // Verify initial data load
136+ const initialRowCount = await paginatedTable . getRowCount ( ) ;
137+ expect ( initialRowCount ) . toBeGreaterThan ( 0 ) ;
138+ expect ( initialRowCount ) . toBeLessThan ( 10000 ) ; // Should not load all rows at once
139+
140+ await paginatedTable . scrollToBottom ( ) ;
141+ await paginatedTable . waitForTableData ( ) ;
142+
143+ // Verify we can load data from the last page
144+ const finalRowCount = await paginatedTable . getRowCount ( ) ;
145+ const lastRowData = await paginatedTable . getRowData ( finalRowCount - 1 ) ;
146+ expect ( lastRowData [ 'Host' ] ) . toBe ( 'host-9999.test' ) ; // Last node in 1000 nodes (0-999)
147+ } ) ;
58148} ) ;
0 commit comments