From b3851c8bc56668d02196d51de8a56e8333addcb2 Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Thu, 2 Apr 2026 13:21:03 -0700 Subject: [PATCH] Fix frontend coverage --- .../filter-editor.component.spec.ts | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts index 985fdebf1..9cd5cf1c2 100644 --- a/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts +++ b/src-ui/src/app/components/document-list/filter-editor/filter-editor.component.spec.ts @@ -1679,6 +1679,50 @@ describe('FilterEditorComponent', () => { ]) })) + it('should convert legacy title filters into full text query when adding a created relative date', fakeAsync(() => { + component.filterRules = [ + { + rule_type: FILTER_TITLE, + value: 'foo', + }, + ] + const dateCreatedDropdown = fixture.debugElement.queryAll( + By.directive(DatesDropdownComponent) + )[0] + component.dateCreatedRelativeDate = RelativeDate.WITHIN_1_WEEK + dateCreatedDropdown.triggerEventHandler('datesSet') + fixture.detectChanges() + tick(400) + expect(component.filterRules).toEqual([ + { + rule_type: FILTER_FULLTEXT_QUERY, + value: 'foo,created:[-1 week to now]', + }, + ]) + })) + + it('should convert simple title filters into full text query when adding a created relative date', fakeAsync(() => { + component.filterRules = [ + { + rule_type: FILTER_SIMPLE_TITLE, + value: 'foo', + }, + ] + const dateCreatedDropdown = fixture.debugElement.queryAll( + By.directive(DatesDropdownComponent) + )[0] + component.dateCreatedRelativeDate = RelativeDate.WITHIN_1_WEEK + dateCreatedDropdown.triggerEventHandler('datesSet') + fixture.detectChanges() + tick(400) + expect(component.filterRules).toEqual([ + { + rule_type: FILTER_FULLTEXT_QUERY, + value: 'foo,created:[-1 week to now]', + }, + ]) + })) + it('should leave relative dates not in quick list intact', fakeAsync(() => { component.textFilterInput.nativeElement.value = 'created:[-2 week to now]' component.textFilterInput.nativeElement.dispatchEvent(new Event('input')) @@ -2020,6 +2064,14 @@ describe('FilterEditorComponent', () => { ] expect(component.generateFilterName()).toEqual('Title: foo') + component.filterRules = [ + { + rule_type: FILTER_SIMPLE_TEXT, + value: 'foo', + }, + ] + expect(component.generateFilterName()).toEqual('Title & content: foo') + component.filterRules = [ { rule_type: FILTER_ASN,