@@ -6,9 +6,11 @@ import {Diagnostics, DiagnosticsTab} from '../Diagnostics';
66
77import {
88 setupEmptyOperationsMock ,
9+ setupMalformedOperationsMock ,
910 setupOperation403Mock ,
1011 setupOperationNetworkErrorMock ,
1112 setupOperationsMock ,
13+ setupPartialMalformedOperationsMock ,
1214} from './operationsMocks' ;
1315
1416test . describe ( 'Operations Tab - Infinite Query' , ( ) => {
@@ -192,6 +194,98 @@ test.describe('Operations Tab - Infinite Query', () => {
192194 expect ( errorDescription . toLowerCase ( ) ) . toContain ( 'network' ) ;
193195 } ) ;
194196
197+ test ( 'handles malformed response without operations array' , async ( { page} ) => {
198+ // Setup malformed response mock (returns status SUCCESS but no operations array)
199+ await setupMalformedOperationsMock ( page ) ;
200+
201+ const pageQueryParams = {
202+ schema : tenantName ,
203+ database : tenantName ,
204+ tenantPage : 'diagnostics' ,
205+ } ;
206+
207+ const tenantPageInstance = new TenantPage ( page ) ;
208+ await tenantPageInstance . goto ( pageQueryParams ) ;
209+
210+ const diagnostics = new Diagnostics ( page ) ;
211+ await diagnostics . clickTab ( DiagnosticsTab . Operations ) ;
212+
213+ // Wait for table to be visible
214+ await diagnostics . operations . waitForTableVisible ( ) ;
215+ await diagnostics . operations . waitForDataLoad ( ) ;
216+
217+ // Verify empty state is shown
218+ const isEmptyVisible = await diagnostics . operations . isEmptyStateVisible ( ) ;
219+ expect ( isEmptyVisible ) . toBe ( true ) ;
220+
221+ // Verify no data rows
222+ const rowCount = await diagnostics . operations . getRowCount ( ) ;
223+ expect ( rowCount ) . toBeLessThanOrEqual ( 1 ) ;
224+
225+ // Verify operations count is 0
226+ const operationsCount = await diagnostics . operations . getOperationsCount ( ) ;
227+ expect ( operationsCount ) . toBe ( 0 ) ;
228+
229+ // Wait to ensure no infinite refetching occurs
230+ await page . waitForTimeout ( 3000 ) ;
231+
232+ // Verify the count is still 0 (no infinite refetching)
233+ const finalOperationsCount = await diagnostics . operations . getOperationsCount ( ) ;
234+ expect ( finalOperationsCount ) . toBe ( 0 ) ;
235+ } ) ;
236+
237+ test ( 'stops pagination when receiving malformed response after valid data' , async ( { page} ) => {
238+ // Setup mock that returns valid data first, then malformed response
239+ await setupPartialMalformedOperationsMock ( page ) ;
240+
241+ const pageQueryParams = {
242+ schema : tenantName ,
243+ database : tenantName ,
244+ tenantPage : 'diagnostics' ,
245+ } ;
246+
247+ const tenantPageInstance = new TenantPage ( page ) ;
248+ await tenantPageInstance . goto ( pageQueryParams ) ;
249+
250+ const diagnostics = new Diagnostics ( page ) ;
251+ await diagnostics . clickTab ( DiagnosticsTab . Operations ) ;
252+
253+ // Wait for initial data to load
254+ await diagnostics . operations . waitForTableVisible ( ) ;
255+ await diagnostics . operations . waitForDataLoad ( ) ;
256+
257+ // Verify initial page loaded (should have 20 operations)
258+ const initialOperationsCount = await diagnostics . operations . getOperationsCount ( ) ;
259+ expect ( initialOperationsCount ) . toBe ( 20 ) ;
260+
261+ // Verify first row data
262+ const firstRowData = await diagnostics . operations . getRowData ( 0 ) ;
263+ expect ( firstRowData [ 'Operation ID' ] ) . toBeTruthy ( ) ;
264+
265+ // Scroll to bottom to trigger next page load
266+ await diagnostics . operations . scrollToBottom ( ) ;
267+
268+ // Wait a bit for potential loading
269+ await page . waitForTimeout ( 2000 ) ;
270+
271+ // Check if loading more appears and disappears
272+ const isLoadingVisible = await diagnostics . operations . isLoadingMoreVisible ( ) ;
273+ if ( isLoadingVisible ) {
274+ await diagnostics . operations . waitForLoadingMoreToDisappear ( ) ;
275+ }
276+
277+ // Verify the count remains at 20 (malformed response didn't add more)
278+ const finalOperationsCount = await diagnostics . operations . getOperationsCount ( ) ;
279+ expect ( finalOperationsCount ) . toBe ( 20 ) ;
280+
281+ // Wait to ensure no infinite refetching occurs
282+ await page . waitForTimeout ( 3000 ) ;
283+
284+ // Verify the count is still 20
285+ const stillFinalCount = await diagnostics . operations . getOperationsCount ( ) ;
286+ expect ( stillFinalCount ) . toBe ( 20 ) ;
287+ } ) ;
288+
195289 test ( 'loads all operations when scrolling to the bottom multiple times' , async ( { page} ) => {
196290 // Setup mocks with 80 operations (4 pages of 20)
197291 await setupOperationsMock ( page , { totalOperations : 80 } ) ;
0 commit comments