From 548c77f6209184bdb926ca71f08529a7edb2727c Mon Sep 17 00:00:00 2001 From: Ashton Galloway Date: Fri, 2 Aug 2024 17:47:44 -0400 Subject: [PATCH] update tests --- ...nFilterInterstitialModalComponent.test.tsx | 25 ++++++++++++------ .../RunFilterInterstitialModalComponent.tsx | 26 +++++++++++-------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/webui/react/src/components/RunFilterInterstitialModalComponent.test.tsx b/webui/react/src/components/RunFilterInterstitialModalComponent.test.tsx index 3284273cdaf..7a05a4fdae1 100644 --- a/webui/react/src/components/RunFilterInterstitialModalComponent.test.tsx +++ b/webui/react/src/components/RunFilterInterstitialModalComponent.test.tsx @@ -109,14 +109,23 @@ describe('RunFilterInterstitialModalComponent', () => { expect(filterFormSetString).toBeDefined(); const filterFormSet = JSON.parse(filterFormSetString || ''); - // TODO: is there a better way to test this expectation? + // TODO: is there a better way to test these expectations? expect(filterFormSet.showArchived).toBeTruthy(); - const [filterGroup, idFilterGroup] = filterFormSet.filterGroup.children?.[0].children || []; - expect(filterGroup).toEqual(expectedFilterGroup); - - const idFilters = idFilterGroup.children; - expect(idFilters.every((f: FormField) => f.operator === '!=')).toBeTruthy(); - expect(idFilters.map((f: FormField) => f.value)).toEqual(expectedExclusions); + const [, , idFilter] = filterFormSet.filterGroup.children; + for (const child of expectedFilterGroup.children) { + expect(filterFormSet.filterGroup.children).toContainEqual(child); + } + + for (const exclusion of expectedExclusions) { + expect(idFilter?.children[0].children).toContainEqual({ + columnName: 'id', + kind: 'field', + location: 'LOCATION_TYPE_RUN', + operator: '!=', + type: 'COLUMN_TYPE_NUMBER', + value: exclusion, + }); + } }); it('calls server with filter describing visual selection', () => { @@ -139,7 +148,7 @@ describe('RunFilterInterstitialModalComponent', () => { const filterFormSet = JSON.parse(filterFormSetString || ''); expect(filterFormSet.showArchived).toBe(false); - const idFilters = filterFormSet.filterGroup.children?.[0].children || []; + const idFilters = filterFormSet.filterGroup.children || []; expect(idFilters.every((f: FormField) => f.operator === '=')).toBe(true); expect(idFilters.map((f: FormField) => f.value)).toEqual(expectedSelection); }); diff --git a/webui/react/src/components/RunFilterInterstitialModalComponent.tsx b/webui/react/src/components/RunFilterInterstitialModalComponent.tsx index 2199232a776..287b3f4a320 100644 --- a/webui/react/src/components/RunFilterInterstitialModalComponent.tsx +++ b/webui/react/src/components/RunFilterInterstitialModalComponent.tsx @@ -78,17 +78,21 @@ export const RunFilterInterstitialModalComponent = forwardRef { if (!isOpen) return NotLoaded; const mergedCanceler = mergeAbortControllers(canceler, closeController.current); - const filter: FilterFormSetWithoutId = { - ...filterFormSet, - filterGroup: combine(getIdsFilter(filterFormSet, selection).filterGroup, 'and', { - columnName: 'searcherType', - kind: 'field', - location: 'LOCATION_TYPE_RUN', - operator: '!=', - type: 'COLUMN_TYPE_TEXT', - value: 'single', - }), - }; + const filterWithSingleFilter = combine(filterFormSet.filterGroup, 'and', { + columnName: 'searcherType', + kind: 'field', + location: 'LOCATION_TYPE_RUN', + operator: '!=', + type: 'COLUMN_TYPE_TEXT', + value: 'single', + }); + const filter: FilterFormSetWithoutId = getIdsFilter( + { + ...filterFormSet, + filterGroup: filterWithSingleFilter, + }, + selection, + ); try { const results = await searchRuns(