@@ -6,8 +6,11 @@ import {Diagnostics, DiagnosticsTab} from '../Diagnostics';
66
77import {
88 setupEmptyOperationsMock ,
9+ setupMalformedOperationsMock ,
910 setupOperation403Mock ,
11+ setupOperationNetworkErrorMock ,
1012 setupOperationsMock ,
13+ setupPartialMalformedOperationsMock ,
1114} from './operationsMocks' ;
1215
1316test . describe ( 'Operations Tab - Infinite Query' , ( ) => {
@@ -160,6 +163,129 @@ test.describe('Operations Tab - Infinite Query', () => {
160163 expect ( accessDeniedTitle ) . toBe ( 'Access denied' ) ;
161164 } ) ;
162165
166+ test ( 'shows error state when operations request returns network error' , async ( { page} ) => {
167+ // Setup network error mock (simulates CORS blocking)
168+ await setupOperationNetworkErrorMock ( page ) ;
169+
170+ const pageQueryParams = {
171+ schema : tenantName ,
172+ database : tenantName ,
173+ tenantPage : 'diagnostics' ,
174+ } ;
175+
176+ const tenantPageInstance = new TenantPage ( page ) ;
177+ await tenantPageInstance . goto ( pageQueryParams ) ;
178+
179+ const diagnostics = new Diagnostics ( page ) ;
180+ await diagnostics . clickTab ( DiagnosticsTab . Operations ) ;
181+ // Wait a bit for potential loading
182+ await page . waitForTimeout ( 2000 ) ;
183+
184+ // Wait for error state to be visible
185+ const isPageErrorVisible = await diagnostics . operations . isPageErrorVisible ( ) ;
186+ expect ( isPageErrorVisible ) . toBe ( true ) ;
187+
188+ // Verify the error title
189+ const errorTitle = await diagnostics . operations . getPageErrorTitle ( ) ;
190+ expect ( errorTitle ) . toBe ( 'Error' ) ;
191+
192+ // Verify the error description shows network error
193+ const errorDescription = await diagnostics . operations . getPageErrorDescription ( ) ;
194+ expect ( errorDescription . toLowerCase ( ) ) . toContain ( 'network' ) ;
195+ } ) ;
196+
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+
163289 test ( 'loads all operations when scrolling to the bottom multiple times' , async ( { page} ) => {
164290 // Setup mocks with 80 operations (4 pages of 20)
165291 await setupOperationsMock ( page , { totalOperations : 80 } ) ;
0 commit comments