From 3d890b6e5d336339e0483c64eb72b2a048c9ee60 Mon Sep 17 00:00:00 2001 From: Herover Date: Sat, 28 Sep 2024 16:17:46 +0200 Subject: [PATCH 1/2] Fix non-dashed empty results after empty segment in makeSankeySegments Co-authored-by: Idkirsch --- .../smartSearch/components/sankeyDiagram/makeSankeySegments.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.ts b/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.ts index feb4d651f7..6fe6febf41 100644 --- a/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.ts +++ b/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.ts @@ -76,7 +76,7 @@ export default function makeSankeySegments( kind: SEGMENT_KIND.PSEUDO_ADD, main: null, side: { - style: SEGMENT_STYLE.FILL, + style: change == 0 ? SEGMENT_STYLE.STROKE : SEGMENT_STYLE.FILL, width: change / maxPeople, }, stats, From ee2f7cf2cd4217ab66e7d0ad1b58509a84550a12 Mon Sep 17 00:00:00 2001 From: Herover Date: Sun, 29 Sep 2024 22:02:14 +0200 Subject: [PATCH 2/2] Add test for adding nothing to empty sankey diagram --- .../sankeyDiagram/makeSankeySegments.spec.ts | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.spec.ts b/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.spec.ts index e1fd122743..d750a8e9d6 100644 --- a/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.spec.ts +++ b/src/features/smartSearch/components/sankeyDiagram/makeSankeySegments.spec.ts @@ -537,4 +537,82 @@ describe('makeSankeySegments()', () => { }, ]); }); + + it('handles adding nothing to empty stream', () => { + const result = makeSankeySegments([ + { + change: 0, + filter: { + config: { + fields: { + first_name: 'aaaaaaaaaaa', + }, + organizations: [1], + }, + op: OPERATION.ADD, + type: FILTER_TYPE.PERSON_DATA, + }, + matches: 0, + result: 0, + }, + { + change: 100, + filter: { + config: { + fields: { + first_name: 'a', + }, + organizations: [1], + }, + op: OPERATION.ADD, + type: FILTER_TYPE.PERSON_DATA, + }, + matches: 100, + result: 100, + }, + ]); + + expect(result).toEqual([ + { + kind: SEGMENT_KIND.EMPTY, + }, + { + kind: SEGMENT_KIND.PSEUDO_ADD, + main: null, + side: { + style: SEGMENT_STYLE.STROKE, + width: 0, + }, + stats: { + change: 0, + input: 0, + matches: 0, + output: 0, + }, + }, + { + kind: SEGMENT_KIND.ADD, + main: { + style: SEGMENT_STYLE.FILL, + width: 0.05, + }, + side: { + style: SEGMENT_STYLE.FILL, + width: 0.95, + }, + stats: { + change: 100, + input: 0, + matches: 100, + output: 100, + }, + }, + { + kind: SEGMENT_KIND.EXIT, + output: 100, + style: SEGMENT_STYLE.FILL, + width: 1, + }, + ]); + }); });