Skip to content

Commit cc2a1dd

Browse files
committed
Handle filter timeout separately
when the filter value population based on option selection times out, don't error out the whole table
1 parent d22ec0d commit cc2a1dd

File tree

4 files changed

+102
-42
lines changed

4 files changed

+102
-42
lines changed

frontend/src/components/filtering/result-filter.test.js

Lines changed: 70 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ describe('ResultFilter', () => {
7171

7272
beforeEach(() => {
7373
jest.clearAllMocks();
74+
if (HttpClient.get.mock) {
75+
HttpClient.get.mockResolvedValue({ ok: true, json: () => [] });
76+
HttpClient.handleResponse.mockResolvedValue([]);
77+
}
7478
});
7579

7680
describe('Rendering', () => {
@@ -251,7 +255,9 @@ describe('ResultFilter', () => {
251255
it('should pass hideFilters prop to ActiveFilters', () => {
252256
renderComponent({ hideFilters: ['project_id'] });
253257

254-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
258+
expect(
259+
screen.getByTestId('filter-table-apply-button'),
260+
).toBeInTheDocument();
255261
});
256262
});
257263

@@ -326,7 +332,9 @@ describe('ResultFilter', () => {
326332
},
327333
);
328334

329-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
335+
expect(
336+
screen.getByTestId('filter-table-apply-button'),
337+
).toBeInTheDocument();
330338
});
331339

332340
it('should filter runs based on input', () => {
@@ -350,12 +358,16 @@ describe('ResultFilter', () => {
350358
fieldSelection: 'run_id',
351359
}}
352360
>
353-
<ResultFilter runs={['run-abc-123', 'run-def-456', 'run-abc-789']} />
361+
<ResultFilter
362+
runs={['run-abc-123', 'run-def-456', 'run-abc-789']}
363+
/>
354364
</FilterContext.Provider>
355365
</MemoryRouter>,
356366
);
357367

358-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
368+
expect(
369+
screen.getByTestId('filter-table-apply-button'),
370+
).toBeInTheDocument();
359371
});
360372

361373
it('should render run multi-select for multi operation mode', () => {
@@ -368,7 +380,9 @@ describe('ResultFilter', () => {
368380
},
369381
);
370382

371-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
383+
expect(
384+
screen.getByTestId('filter-table-apply-button'),
385+
).toBeInTheDocument();
372386
});
373387
});
374388

@@ -398,7 +412,9 @@ describe('ResultFilter', () => {
398412
},
399413
);
400414

401-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
415+
expect(
416+
screen.getByTestId('filter-table-apply-button'),
417+
).toBeInTheDocument();
402418
});
403419
});
404420

@@ -457,25 +473,33 @@ describe('ResultFilter', () => {
457473
it('should accept maxHeight prop', () => {
458474
renderComponent({ maxHeight: '400px' });
459475

460-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
476+
expect(
477+
screen.getByTestId('filter-table-apply-button'),
478+
).toBeInTheDocument();
461479
});
462480

463481
it('should use default maxHeight when not provided', () => {
464482
renderComponent();
465483

466-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
484+
expect(
485+
screen.getByTestId('filter-table-apply-button'),
486+
).toBeInTheDocument();
467487
});
468488

469489
it('should accept runs prop', () => {
470490
renderComponent({ runs: ['run-1', 'run-2', 'run-3'] });
471491

472-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
492+
expect(
493+
screen.getByTestId('filter-table-apply-button'),
494+
).toBeInTheDocument();
473495
});
474496

475497
it('should handle empty runs array', () => {
476498
renderComponent({ runs: [] });
477499

478-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
500+
expect(
501+
screen.getByTestId('filter-table-apply-button'),
502+
).toBeInTheDocument();
479503
});
480504
});
481505

@@ -533,7 +557,9 @@ describe('ResultFilter', () => {
533557
},
534558
);
535559

536-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
560+
expect(
561+
screen.getByTestId('filter-table-apply-button'),
562+
).toBeInTheDocument();
537563
});
538564
});
539565

@@ -565,7 +591,9 @@ describe('ResultFilter', () => {
565591
);
566592

567593
// Component should render with context
568-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
594+
expect(
595+
screen.getByTestId('filter-table-apply-button'),
596+
).toBeInTheDocument();
569597
});
570598
});
571599

@@ -592,7 +620,9 @@ describe('ResultFilter', () => {
592620
},
593621
);
594622

595-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
623+
expect(
624+
screen.getByTestId('filter-table-apply-button'),
625+
).toBeInTheDocument();
596626
});
597627

598628
it('should handle run selection in multi mode', () => {
@@ -605,7 +635,9 @@ describe('ResultFilter', () => {
605635
},
606636
);
607637

608-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
638+
expect(
639+
screen.getByTestId('filter-table-apply-button'),
640+
).toBeInTheDocument();
609641
});
610642

611643
it('should handle empty run input', () => {
@@ -618,7 +650,9 @@ describe('ResultFilter', () => {
618650
},
619651
);
620652

621-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
653+
expect(
654+
screen.getByTestId('filter-table-apply-button'),
655+
).toBeInTheDocument();
622656
});
623657
});
624658

@@ -633,7 +667,9 @@ describe('ResultFilter', () => {
633667
},
634668
);
635669

636-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
670+
expect(
671+
screen.getByTestId('filter-table-apply-button'),
672+
).toBeInTheDocument();
637673
});
638674

639675
it('should handle result selection in multi mode', () => {
@@ -646,7 +682,9 @@ describe('ResultFilter', () => {
646682
},
647683
);
648684

649-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
685+
expect(
686+
screen.getByTestId('filter-table-apply-button'),
687+
).toBeInTheDocument();
650688
});
651689
});
652690

@@ -747,7 +785,9 @@ describe('ResultFilter', () => {
747785
},
748786
);
749787

750-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
788+
expect(
789+
screen.getByTestId('filter-table-apply-button'),
790+
).toBeInTheDocument();
751791
});
752792

753793
it('should handle value options in multi mode', () => {
@@ -760,7 +800,9 @@ describe('ResultFilter', () => {
760800
},
761801
);
762802

763-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
803+
expect(
804+
screen.getByTestId('filter-table-apply-button'),
805+
).toBeInTheDocument();
764806
});
765807
});
766808

@@ -776,7 +818,9 @@ describe('ResultFilter', () => {
776818
);
777819

778820
// All toggles should be available through context
779-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
821+
expect(
822+
screen.getByTestId('filter-table-apply-button'),
823+
).toBeInTheDocument();
780824
});
781825
});
782826

@@ -845,7 +889,7 @@ describe('ResultFilter', () => {
845889
fieldSelection: 'metadata.browser',
846890
filterMode: 'text',
847891
operationMode: 'single',
848-
}
892+
},
849893
);
850894

851895
await waitFor(() => {
@@ -854,7 +898,9 @@ describe('ResultFilter', () => {
854898
});
855899

856900
it('should fetch with days=90 parameter', async () => {
857-
HttpClient.get.mockReturnValue(Promise.resolve({ ok: true, json: () => [] }));
901+
HttpClient.get.mockReturnValue(
902+
Promise.resolve({ ok: true, json: () => [] }),
903+
);
858904
HttpClient.handleResponse.mockReturnValue([]);
859905

860906
renderComponent(
@@ -863,13 +909,13 @@ describe('ResultFilter', () => {
863909
fieldSelection: 'metadata.browser',
864910
filterMode: 'text',
865911
operationMode: 'single',
866-
}
912+
},
867913
);
868914

869915
await waitFor(() => {
870916
expect(HttpClient.get).toHaveBeenCalledWith(
871917
expect.anything(),
872-
expect.objectContaining({ days: 90 })
918+
expect.objectContaining({ days: 90 }),
873919
);
874920
});
875921
});

frontend/src/components/filtering/run-filter.test.js

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,9 @@ describe('RunFilter', () => {
220220
it('should pass hideFilters prop to ActiveFilters', () => {
221221
renderComponent({ hideFilters: ['project_id'] });
222222

223-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
223+
expect(
224+
screen.getByTestId('filter-table-apply-button'),
225+
).toBeInTheDocument();
224226
});
225227
});
226228

@@ -261,21 +263,27 @@ describe('RunFilter', () => {
261263
</MemoryRouter>,
262264
);
263265

264-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
266+
expect(
267+
screen.getByTestId('filter-table-apply-button'),
268+
).toBeInTheDocument();
265269
});
266270
});
267271

268272
describe('Component Props', () => {
269273
it('should accept maxHeight prop', () => {
270274
renderComponent({ maxHeight: '400px' });
271275

272-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
276+
expect(
277+
screen.getByTestId('filter-table-apply-button'),
278+
).toBeInTheDocument();
273279
});
274280

275281
it('should use default maxHeight when not provided', () => {
276282
renderComponent();
277283

278-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
284+
expect(
285+
screen.getByTestId('filter-table-apply-button'),
286+
).toBeInTheDocument();
279287
});
280288
});
281289

@@ -327,7 +335,9 @@ describe('RunFilter', () => {
327335
);
328336

329337
// Bool select should be available (though not open)
330-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
338+
expect(
339+
screen.getByTestId('filter-table-apply-button'),
340+
).toBeInTheDocument();
331341
});
332342
});
333343

@@ -352,7 +362,9 @@ describe('RunFilter', () => {
352362
renderComponent(
353363
{},
354364
{
355-
activeFilters: [{ field: 'env', operator: 'contains', value: 'prod' }],
365+
activeFilters: [
366+
{ field: 'env', operator: 'contains', value: 'prod' },
367+
],
356368
boolSelection: 'True',
357369
fieldSelection: 'source',
358370
filteredFieldOptions: [
@@ -397,7 +409,9 @@ describe('RunFilter', () => {
397409
},
398410
);
399411

400-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
412+
expect(
413+
screen.getByTestId('filter-table-apply-button'),
414+
).toBeInTheDocument();
401415
});
402416
});
403417

@@ -419,13 +433,17 @@ describe('RunFilter', () => {
419433
it('should set empty valueOptions on mount', () => {
420434
renderComponent({}, { fieldSelection: null });
421435

422-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
436+
expect(
437+
screen.getByTestId('filter-table-apply-button'),
438+
).toBeInTheDocument();
423439
});
424440

425441
it('should update valueOptions when fieldSelection changes', () => {
426442
const { rerender } = renderComponent({}, { fieldSelection: 'source' });
427443

428-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
444+
expect(
445+
screen.getByTestId('filter-table-apply-button'),
446+
).toBeInTheDocument();
429447

430448
// Change fieldSelection
431449
rerender(
@@ -441,7 +459,9 @@ describe('RunFilter', () => {
441459
</MemoryRouter>,
442460
);
443461

444-
expect(screen.getByTestId('filter-table-apply-button')).toBeInTheDocument();
462+
expect(
463+
screen.getByTestId('filter-table-apply-button'),
464+
).toBeInTheDocument();
445465
});
446466
});
447467
});

frontend/src/pages/result-list.test.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/* eslint-env jest */
2-
import React from 'react';
3-
import { render, screen, waitFor, fireEvent } from '@testing-library/react';
2+
import { render, screen, waitFor } from '@testing-library/react';
43
import { MemoryRouter } from 'react-router-dom';
54
import ResultList from './result-list';
65
import { IbutsuContext } from '../components/contexts/ibutsu-context';
@@ -199,9 +198,7 @@ describe('ResultList', () => {
199198
HttpClient.handleResponse.mockResolvedValue(mockResponse);
200199

201200
const filterContext = {
202-
activeFilters: [
203-
{ field: 'result', operator: 'eq', value: 'passed' },
204-
],
201+
activeFilters: [{ field: 'result', operator: 'eq', value: 'passed' }],
205202
};
206203

207204
renderComponent({}, filterContext);

frontend/src/pages/run-list.test.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
/* eslint-env jest */
2-
import React from 'react';
32
import { render, screen, waitFor } from '@testing-library/react';
43
import { MemoryRouter } from 'react-router-dom';
54
import RunList from './run-list';
@@ -388,8 +387,6 @@ describe('RunList', () => {
388387
expect(HttpClient.get).toHaveBeenCalled();
389388
});
390389

391-
const callCount = HttpClient.get.mock.calls.length;
392-
393390
// Change filters
394391
const newFilterContext = {
395392
activeFilters: [{ field: 'env', operator: 'eq', value: 'staging' }],

0 commit comments

Comments
 (0)