From 9c4d09c91cf01a010dc7f0f3a3989a20ca12c21a Mon Sep 17 00:00:00 2001 From: shamoon <4887959+shamoon@users.noreply.github.com> Date: Tue, 7 Oct 2025 13:45:04 -0700 Subject: [PATCH] More frontend coverage --- .../workflow-edit-dialog.component.spec.ts | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts index c459c4cbd..43887b0eb 100644 --- a/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts +++ b/src-ui/src/app/components/common/edit-dialog/workflow-edit-dialog/workflow-edit-dialog.component.spec.ts @@ -512,6 +512,32 @@ describe('WorkflowEditDialogComponent', () => { expect(formValues.triggers[0].filter_has_storage_path).toEqual(7) }) + it('should convert multi-value condition values when aggregating filters', () => { + component.object = undefined + component.addTrigger() + const triggerGroup = component.triggerFields.at(0) as FormGroup + + const setCondition = (type: TriggerConditionType, value: number): void => { + const condition = component.addCondition(triggerGroup) as FormGroup + condition.get('type').setValue(type) + condition.get('values').setValue(value) + } + + setCondition(TriggerConditionType.TagsAll, 11) + setCondition(TriggerConditionType.TagsNone, 12) + setCondition(TriggerConditionType.CorrespondentNot, 13) + setCondition(TriggerConditionType.DocumentTypeNot, 14) + setCondition(TriggerConditionType.StoragePathNot, 15) + + const formValues = component['getFormValues']() + + expect(formValues.triggers[0].filter_has_all_tags).toEqual([11]) + expect(formValues.triggers[0].filter_has_not_tags).toEqual([12]) + expect(formValues.triggers[0].filter_has_not_correspondents).toEqual([13]) + expect(formValues.triggers[0].filter_has_not_document_types).toEqual([14]) + expect(formValues.triggers[0].filter_has_not_storage_paths).toEqual([15]) + }) + it('should reuse condition type options and update disabled state', () => { component.object = undefined component.addTrigger() @@ -616,6 +642,37 @@ describe('WorkflowEditDialogComponent', () => { expect(component.addCondition(triggerGroup)).toBeNull() }) + it('should skip condition definitions without handlers when building form array', () => { + const originalDefinitions = component.conditionDefinitions + component.conditionDefinitions = [ + { + id: 999, + name: 'Unsupported', + inputType: 'text', + allowMultipleEntries: false, + allowMultipleValues: false, + } as any, + ] + + const trigger = { + filter_has_tags: [], + filter_has_all_tags: [], + filter_has_not_tags: [], + filter_has_not_correspondents: [], + filter_has_not_document_types: [], + filter_has_not_storage_paths: [], + filter_has_correspondent: null, + filter_has_document_type: null, + filter_has_storage_path: null, + filter_custom_field_query: null, + } as any + + const conditions = component['buildConditionFormArray'](trigger) + expect(conditions.length).toBe(0) + + component.conditionDefinitions = originalDefinitions + }) + it('should return null when adding condition for unknown trigger form group', () => { expect(component.addCondition(new FormGroup({}) as any)).toBeNull() }) @@ -716,6 +773,17 @@ describe('WorkflowEditDialogComponent', () => { ).toBe(true) }) + it('should return empty select items when definition is missing', () => { + const originalDefinitions = component.conditionDefinitions + component.conditionDefinitions = [] + + expect( + component.getConditionSelectItems(TriggerConditionType.CorrespondentIs) + ).toEqual([]) + + component.conditionDefinitions = originalDefinitions + }) + it('should handle custom field query selection change and validation states', () => { const formGroup = new FormGroup({ values: new FormControl(null),