@@ -6,7 +6,15 @@ import {NavigationTabs, TenantPage} from '../TenantPage';
66import { longRunningQuery } from '../constants' ;
77import { QueryEditor } from '../queryEditor/models/QueryEditor' ;
88
9- import { Diagnostics , DiagnosticsTab , QueriesSwitch } from './Diagnostics' ;
9+ import {
10+ Diagnostics ,
11+ DiagnosticsTab ,
12+ QueriesSwitch ,
13+ TopShardsHistoricalColumns ,
14+ TopShardsImmediateColumns ,
15+ TopShardsMode ,
16+ } from './Diagnostics' ;
17+ import { setupTopShardsHistoryMock } from './mocks' ;
1018
1119test . describe ( 'Diagnostics tab' , async ( ) => {
1220 test ( 'Info tab shows main page elements' , async ( { page} ) => {
@@ -170,4 +178,135 @@ test.describe('Diagnostics tab', async () => {
170178 await diagnostics . table . waitForCellValueByHeader ( 1 , 'Query text' , longRunningQuery ) ,
171179 ) . toBe ( true ) ;
172180 } ) ;
181+
182+ test ( 'TopShards tab defaults to Immediate mode' , async ( { page} ) => {
183+ const pageQueryParams = {
184+ schema : tenantName ,
185+ database : tenantName ,
186+ tenantPage : 'diagnostics' ,
187+ diagnosticsTab : 'topShards' ,
188+ } ;
189+ const tenantPage = new TenantPage ( page ) ;
190+ await tenantPage . goto ( pageQueryParams ) ;
191+
192+ const diagnostics = new Diagnostics ( page ) ;
193+
194+ // Verify Immediate mode is selected by default
195+ expect ( await diagnostics . getSelectedTopShardsMode ( ) ) . toBe ( TopShardsMode . Immediate ) ;
196+ } ) ;
197+
198+ test ( 'TopShards immediate tab shows all expected column headers' , async ( { page} ) => {
199+ const pageQueryParams = {
200+ schema : tenantName ,
201+ database : tenantName ,
202+ tenantPage : 'diagnostics' ,
203+ diagnosticsTab : 'topShards' ,
204+ } ;
205+ const tenantPage = new TenantPage ( page ) ;
206+ await tenantPage . goto ( pageQueryParams ) ;
207+
208+ const diagnostics = new Diagnostics ( page ) ;
209+
210+ // Verify table has data
211+ await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
212+ await expect ( diagnostics . table . getRowCount ( ) ) . resolves . toBeGreaterThan ( 0 ) ;
213+ // Verify column headers exist
214+ await diagnostics . table . verifyHeaders ( TopShardsImmediateColumns ) ;
215+ } ) ;
216+
217+ test ( 'TopShards history tab shows all expected column headers' , async ( { page} ) => {
218+ const pageQueryParams = {
219+ schema : tenantName ,
220+ database : tenantName ,
221+ tenantPage : 'diagnostics' ,
222+ diagnosticsTab : 'topShards' ,
223+ } ;
224+ const tenantPage = new TenantPage ( page ) ;
225+ await tenantPage . goto ( pageQueryParams ) ;
226+
227+ const diagnostics = new Diagnostics ( page ) ;
228+ await diagnostics . selectTopShardsMode ( TopShardsMode . Historical ) ;
229+ // Verify table has data
230+ await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
231+ await expect ( diagnostics . table . getRowCount ( ) ) . resolves . toBeGreaterThan ( 0 ) ;
232+
233+ // Verify column headers exist
234+ await diagnostics . table . verifyHeaders ( TopShardsHistoricalColumns ) ;
235+ } ) ;
236+
237+ test ( 'TopShards tab first row has values for all columns in Immediate mode' , async ( { page} ) => {
238+ const pageQueryParams = {
239+ schema : tenantName ,
240+ database : tenantName ,
241+ tenantPage : 'diagnostics' ,
242+ diagnosticsTab : 'topShards' ,
243+ } ;
244+ const tenantPage = new TenantPage ( page ) ;
245+ await tenantPage . goto ( pageQueryParams ) ;
246+
247+ const diagnostics = new Diagnostics ( page ) ;
248+
249+ // Verify table has data
250+ await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
251+ await expect ( diagnostics . table . getRowCount ( ) ) . resolves . toBeGreaterThan ( 0 ) ;
252+
253+ // Verify first row has non-empty values for all columns
254+ for ( const column of TopShardsImmediateColumns ) {
255+ const columnValue = await diagnostics . table . getCellValueByHeader ( 1 , column ) ;
256+ expect ( columnValue . trim ( ) ) . toBeTruthy ( ) ;
257+ }
258+ } ) ;
259+
260+ test ( 'TopShards tab first row has values for all columns in History mode' , async ( { page} ) => {
261+ // Setup mock for TopShards tab in History mode
262+ await setupTopShardsHistoryMock ( page ) ;
263+
264+ // Now navigate to diagnostics page to check topShards
265+ const pageQueryParams = {
266+ schema : tenantName ,
267+ database : tenantName ,
268+ tenantPage : 'diagnostics' ,
269+ diagnosticsTab : 'topShards' ,
270+ } ;
271+ const tenantPage = new TenantPage ( page ) ;
272+ await tenantPage . goto ( pageQueryParams ) ;
273+
274+ const diagnostics = new Diagnostics ( page ) ;
275+ await diagnostics . selectTopShardsMode ( TopShardsMode . Historical ) ;
276+
277+ // Verify table has data
278+ await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
279+ await expect ( diagnostics . table . getRowCount ( ) ) . resolves . toBeGreaterThan ( 0 ) ;
280+
281+ // Verify first row has non-empty values for all columns
282+ for ( const column of TopShardsHistoricalColumns ) {
283+ const columnValue = await diagnostics . table . getCellValueByHeader ( 1 , column ) ;
284+ expect ( columnValue . trim ( ) ) . toBeTruthy ( ) ;
285+ }
286+ } ) ;
287+
288+ test ( 'TopShards tab can switch back to Immediate mode from Historical mode' , async ( { page} ) => {
289+ const pageQueryParams = {
290+ schema : tenantName ,
291+ database : tenantName ,
292+ tenantPage : 'diagnostics' ,
293+ diagnosticsTab : 'topShards' ,
294+ } ;
295+ const tenantPage = new TenantPage ( page ) ;
296+ await tenantPage . goto ( pageQueryParams ) ;
297+
298+ const diagnostics = new Diagnostics ( page ) ;
299+
300+ // Switch to Historical mode
301+ await diagnostics . selectTopShardsMode ( TopShardsMode . Historical ) ;
302+ expect ( await diagnostics . getSelectedTopShardsMode ( ) ) . toBe ( TopShardsMode . Historical ) ;
303+
304+ // Switch back to Immediate mode
305+ await diagnostics . selectTopShardsMode ( TopShardsMode . Immediate ) ;
306+ expect ( await diagnostics . getSelectedTopShardsMode ( ) ) . toBe ( TopShardsMode . Immediate ) ;
307+
308+ // Verify table still has data after switching back
309+ await expect ( diagnostics . table . isVisible ( ) ) . resolves . toBe ( true ) ;
310+ await expect ( diagnostics . table . getRowCount ( ) ) . resolves . toBeGreaterThan ( 0 ) ;
311+ } ) ;
173312} ) ;
0 commit comments