@startsimpli/funnels 0.4.6 → 0.4.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/api/client.test.ts +76 -76
- package/src/api/client.ts +16 -16
- package/src/components/FilterRuleEditor/FilterRuleEditor.stories.tsx +24 -24
- package/src/components/FilterRuleEditor/FilterRuleEditor.test.tsx +39 -39
- package/src/components/FilterRuleEditor/FilterRuleEditor.tsx +1 -1
- package/src/components/FilterRuleEditor/RuleRow.tsx +8 -8
- package/src/components/FunnelCard/FunnelCard.stories.tsx +118 -118
- package/src/components/FunnelCard/FunnelCard.test.ts +48 -48
- package/src/components/FunnelCard/FunnelCard.test.tsx +40 -40
- package/src/components/FunnelCard/FunnelCard.tsx +3 -3
- package/src/components/FunnelPreview/FunnelPreview.test.tsx +63 -63
- package/src/components/FunnelPreview/FunnelPreview.tsx +11 -11
- package/src/components/FunnelPreview/StageBreakdown.tsx +5 -5
- package/src/components/FunnelPreview/example.tsx +43 -43
- package/src/components/FunnelRunHistory/FunnelRunHistory.stories.tsx +70 -70
- package/src/components/FunnelRunHistory/FunnelRunHistory.test.tsx +63 -63
- package/src/components/FunnelRunHistory/FunnelRunHistory.tsx +12 -12
- package/src/components/FunnelRunHistory/RunDetailsModal.tsx +5 -5
- package/src/components/FunnelRunHistory/RunFilters.tsx +8 -8
- package/src/components/FunnelRunHistory/RunRow.tsx +7 -7
- package/src/components/FunnelRunHistory/StageBreakdownList.tsx +9 -9
- package/src/components/FunnelRunHistory/types.ts +6 -6
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.stories.tsx +41 -41
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.test.tsx +6 -6
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.tsx +5 -5
- package/src/components/FunnelStageBuilder/StageActions.test.tsx +7 -7
- package/src/components/FunnelStageBuilder/StageActions.tsx +4 -4
- package/src/components/FunnelStageBuilder/StageCard.tsx +3 -3
- package/src/components/FunnelStageBuilder/StageForm.tsx +14 -14
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.stories.tsx +42 -42
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.test.tsx +31 -31
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.tsx +4 -4
- package/src/components/FunnelVisualFlow/StageNode.tsx +8 -8
- package/src/components/FunnelVisualFlow/example.tsx +7 -7
- package/src/core/engine.test.ts +271 -271
- package/src/core/engine.ts +60 -60
- package/src/core/evaluator.example.ts +31 -31
- package/src/core/evaluator.test.ts +92 -92
- package/src/core/evaluator.ts +23 -23
- package/src/core/field-resolver.example.ts +1 -1
- package/src/core/field-resolver.test.ts +4 -4
- package/src/store/create-funnel-store.test.ts +32 -32
- package/src/store/create-funnel-store.ts +3 -3
- package/src/store/types.ts +2 -2
- package/src/types/index.ts +64 -64
|
@@ -36,88 +36,88 @@ const baseFunnel: Funnel = {
|
|
|
36
36
|
name: 'Series A Investor Qualification',
|
|
37
37
|
description: 'Identifies qualified Series A investors based on stage focus, check size, and geography.',
|
|
38
38
|
status: 'active',
|
|
39
|
-
|
|
39
|
+
inputType: 'contacts',
|
|
40
40
|
stages: [
|
|
41
41
|
{
|
|
42
42
|
id: 'stage-1',
|
|
43
43
|
order: 0,
|
|
44
44
|
name: 'Stage Filter',
|
|
45
|
-
|
|
45
|
+
filterLogic: 'AND',
|
|
46
46
|
rules: [
|
|
47
|
-
{
|
|
47
|
+
{ fieldPath: 'firm.stage', operator: 'in', value: ['Series A', 'Multi-Stage'] },
|
|
48
48
|
],
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
matchAction: 'tag_continue',
|
|
50
|
+
noMatchAction: 'exclude',
|
|
51
|
+
matchTags: ['qualified_stage'],
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
54
|
id: 'stage-2',
|
|
55
55
|
order: 1,
|
|
56
56
|
name: 'Check Size Filter',
|
|
57
|
-
|
|
57
|
+
filterLogic: 'AND',
|
|
58
58
|
rules: [
|
|
59
|
-
{
|
|
60
|
-
{
|
|
61
|
-
{
|
|
59
|
+
{ fieldPath: 'firm.check_size_min', operator: 'lte', value: 5000000 },
|
|
60
|
+
{ fieldPath: 'firm.check_size_max', operator: 'gte', value: 3000000 },
|
|
61
|
+
{ fieldPath: 'firm.active', operator: 'is_true', value: null },
|
|
62
62
|
],
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
matchAction: 'tag_continue',
|
|
64
|
+
noMatchAction: 'tag_exclude',
|
|
65
|
+
matchTags: ['qualified_check_size'],
|
|
66
|
+
noMatchTags: ['excluded_check_size'],
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
id: 'stage-3',
|
|
70
70
|
order: 2,
|
|
71
71
|
name: 'Geography Filter',
|
|
72
|
-
|
|
72
|
+
filterLogic: 'OR',
|
|
73
73
|
rules: [
|
|
74
|
-
{
|
|
74
|
+
{ fieldPath: 'firm.geography', operator: 'has_any', value: ['US', 'North America'] },
|
|
75
75
|
],
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
matchAction: 'tag_continue',
|
|
77
|
+
noMatchAction: 'exclude',
|
|
78
|
+
matchTags: ['qualified_geography'],
|
|
79
79
|
},
|
|
80
80
|
{
|
|
81
81
|
id: 'stage-4',
|
|
82
82
|
order: 3,
|
|
83
83
|
name: 'Industry Filter',
|
|
84
|
-
|
|
84
|
+
filterLogic: 'OR',
|
|
85
85
|
rules: [
|
|
86
|
-
{
|
|
86
|
+
{ fieldPath: 'firm.industries', operator: 'has_any', value: ['SaaS', 'Enterprise'] },
|
|
87
87
|
],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
88
|
+
matchAction: 'tag_continue',
|
|
89
|
+
noMatchAction: 'exclude',
|
|
90
|
+
matchTags: ['qualified_industry'],
|
|
91
91
|
},
|
|
92
92
|
{
|
|
93
93
|
id: 'stage-5',
|
|
94
94
|
order: 4,
|
|
95
95
|
name: 'Final Qualification',
|
|
96
|
-
|
|
96
|
+
filterLogic: 'AND',
|
|
97
97
|
rules: [
|
|
98
|
-
{
|
|
98
|
+
{ fieldPath: 'tags', operator: 'has_all', value: ['qualified_stage', 'qualified_check_size', 'qualified_geography'] },
|
|
99
99
|
],
|
|
100
|
-
|
|
101
|
-
|
|
100
|
+
matchAction: 'output',
|
|
101
|
+
noMatchAction: 'exclude',
|
|
102
102
|
},
|
|
103
103
|
],
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
105
|
+
updatedAt: '2024-01-15T10:30:00Z',
|
|
106
106
|
};
|
|
107
107
|
|
|
108
108
|
const completedRun: FunnelRun = {
|
|
109
109
|
id: 'run-1',
|
|
110
|
-
|
|
110
|
+
funnelId: 'funnel-1',
|
|
111
111
|
status: 'completed',
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
triggerType: 'manual',
|
|
113
|
+
startedAt: '2024-01-15T10:00:00Z',
|
|
114
|
+
completedAt: '2024-01-15T10:05:00Z',
|
|
115
|
+
durationMs: 300000,
|
|
116
|
+
totalInput: 83061,
|
|
117
|
+
totalMatched: 235,
|
|
118
|
+
totalExcluded: 82826,
|
|
119
|
+
totalTagged: 235,
|
|
120
|
+
stageStats: {},
|
|
121
121
|
};
|
|
122
122
|
|
|
123
123
|
// Stories
|
|
@@ -178,7 +178,7 @@ export const Running: Story = {
|
|
|
178
178
|
latestRun: {
|
|
179
179
|
...completedRun,
|
|
180
180
|
status: 'running',
|
|
181
|
-
|
|
181
|
+
completedAt: undefined,
|
|
182
182
|
},
|
|
183
183
|
},
|
|
184
184
|
};
|
|
@@ -214,9 +214,9 @@ export const OneStage: Story = {
|
|
|
214
214
|
},
|
|
215
215
|
latestRun: {
|
|
216
216
|
...completedRun,
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
totalInput: 1000,
|
|
218
|
+
totalMatched: 450,
|
|
219
|
+
totalExcluded: 550,
|
|
220
220
|
},
|
|
221
221
|
},
|
|
222
222
|
};
|
|
@@ -229,12 +229,12 @@ export const TenStages: Story = {
|
|
|
229
229
|
id: `stage-${i}`,
|
|
230
230
|
order: i,
|
|
231
231
|
name: `Stage ${i + 1}: Filter ${i + 1}`,
|
|
232
|
-
|
|
232
|
+
filterLogic: 'AND' as const,
|
|
233
233
|
rules: [
|
|
234
|
-
{
|
|
234
|
+
{ fieldPath: `field${i}`, operator: 'eq' as const, value: i },
|
|
235
235
|
],
|
|
236
|
-
|
|
237
|
-
|
|
236
|
+
matchAction: 'continue' as const,
|
|
237
|
+
noMatchAction: 'exclude' as const,
|
|
238
238
|
})),
|
|
239
239
|
name: 'Complex Multi-Stage Funnel',
|
|
240
240
|
description: 'Demonstrates card with many stages.',
|
|
@@ -248,9 +248,9 @@ export const HighMatchRate: Story = {
|
|
|
248
248
|
funnel: baseFunnel,
|
|
249
249
|
latestRun: {
|
|
250
250
|
...completedRun,
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
251
|
+
totalInput: 1000,
|
|
252
|
+
totalMatched: 950,
|
|
253
|
+
totalExcluded: 50,
|
|
254
254
|
},
|
|
255
255
|
},
|
|
256
256
|
};
|
|
@@ -260,9 +260,9 @@ export const LowMatchRate: Story = {
|
|
|
260
260
|
funnel: baseFunnel,
|
|
261
261
|
latestRun: {
|
|
262
262
|
...completedRun,
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
263
|
+
totalInput: 100000,
|
|
264
|
+
totalMatched: 12,
|
|
265
|
+
totalExcluded: 99988,
|
|
266
266
|
},
|
|
267
267
|
},
|
|
268
268
|
};
|
|
@@ -272,8 +272,8 @@ export const ZeroMatches: Story = {
|
|
|
272
272
|
funnel: baseFunnel,
|
|
273
273
|
latestRun: {
|
|
274
274
|
...completedRun,
|
|
275
|
-
|
|
276
|
-
|
|
275
|
+
totalMatched: 0,
|
|
276
|
+
totalExcluded: 83061,
|
|
277
277
|
},
|
|
278
278
|
},
|
|
279
279
|
};
|
|
@@ -317,52 +317,52 @@ export const RecipeFunnel: Story = {
|
|
|
317
317
|
name: 'Quick Easy Dinner Recommendations',
|
|
318
318
|
description: 'Filters recipes for vegetarian, gluten-free, quick prep, easy difficulty.',
|
|
319
319
|
status: 'active',
|
|
320
|
-
|
|
320
|
+
inputType: 'any',
|
|
321
321
|
stages: [
|
|
322
322
|
{
|
|
323
323
|
id: 'stage-1',
|
|
324
324
|
order: 0,
|
|
325
325
|
name: 'Dietary Restrictions',
|
|
326
|
-
|
|
326
|
+
filterLogic: 'AND',
|
|
327
327
|
rules: [
|
|
328
|
-
{
|
|
328
|
+
{ fieldPath: 'dietary_restrictions', operator: 'has_all', value: ['vegetarian', 'gluten-free'] },
|
|
329
329
|
],
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
330
|
+
matchAction: 'tag_continue',
|
|
331
|
+
noMatchAction: 'exclude',
|
|
332
|
+
matchTags: ['meets_dietary_needs'],
|
|
333
333
|
},
|
|
334
334
|
{
|
|
335
335
|
id: 'stage-2',
|
|
336
336
|
order: 1,
|
|
337
337
|
name: 'Time Constraint',
|
|
338
|
-
|
|
338
|
+
filterLogic: 'AND',
|
|
339
339
|
rules: [
|
|
340
|
-
{
|
|
340
|
+
{ fieldPath: 'prep_time_minutes', operator: 'lte', value: 30 },
|
|
341
341
|
],
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
342
|
+
matchAction: 'tag_continue',
|
|
343
|
+
noMatchAction: 'exclude',
|
|
344
|
+
matchTags: ['quick_prep'],
|
|
345
345
|
},
|
|
346
346
|
{
|
|
347
347
|
id: 'stage-3',
|
|
348
348
|
order: 2,
|
|
349
349
|
name: 'Difficulty Level',
|
|
350
|
-
|
|
350
|
+
filterLogic: 'OR',
|
|
351
351
|
rules: [
|
|
352
|
-
{
|
|
352
|
+
{ fieldPath: 'difficulty', operator: 'in', value: ['easy', 'medium'] },
|
|
353
353
|
],
|
|
354
|
-
|
|
355
|
-
|
|
354
|
+
matchAction: 'output',
|
|
355
|
+
noMatchAction: 'exclude',
|
|
356
356
|
},
|
|
357
357
|
],
|
|
358
|
-
|
|
359
|
-
|
|
358
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
359
|
+
updatedAt: '2024-01-15T10:30:00Z',
|
|
360
360
|
},
|
|
361
361
|
latestRun: {
|
|
362
362
|
...completedRun,
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
totalInput: 5420,
|
|
364
|
+
totalMatched: 87,
|
|
365
|
+
totalExcluded: 5333,
|
|
366
366
|
},
|
|
367
367
|
},
|
|
368
368
|
};
|
|
@@ -374,55 +374,55 @@ export const LeadScoringFunnel: Story = {
|
|
|
374
374
|
name: 'Enterprise Lead Scoring',
|
|
375
375
|
description: 'Scores and qualifies enterprise leads based on company size, engagement, and fit.',
|
|
376
376
|
status: 'active',
|
|
377
|
-
|
|
377
|
+
inputType: 'any',
|
|
378
378
|
stages: [
|
|
379
379
|
{
|
|
380
380
|
id: 'stage-1',
|
|
381
381
|
order: 0,
|
|
382
382
|
name: 'Company Size',
|
|
383
|
-
|
|
383
|
+
filterLogic: 'AND',
|
|
384
384
|
rules: [
|
|
385
|
-
{
|
|
385
|
+
{ fieldPath: 'company.employee_count', operator: 'gte', value: 100 },
|
|
386
386
|
],
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
387
|
+
matchAction: 'tag_continue',
|
|
388
|
+
noMatchAction: 'tag_continue',
|
|
389
|
+
matchTags: ['enterprise_size'],
|
|
390
|
+
noMatchTags: ['smb_size'],
|
|
391
391
|
},
|
|
392
392
|
{
|
|
393
393
|
id: 'stage-2',
|
|
394
394
|
order: 1,
|
|
395
395
|
name: 'Engagement Score',
|
|
396
|
-
|
|
396
|
+
filterLogic: 'OR',
|
|
397
397
|
rules: [
|
|
398
|
-
{
|
|
399
|
-
{
|
|
398
|
+
{ fieldPath: 'engagement.email_opens', operator: 'gte', value: 5 },
|
|
399
|
+
{ fieldPath: 'engagement.demo_requested', operator: 'is_true', value: null },
|
|
400
400
|
],
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
401
|
+
matchAction: 'tag_continue',
|
|
402
|
+
noMatchAction: 'tag_continue',
|
|
403
|
+
matchTags: ['engaged'],
|
|
404
404
|
},
|
|
405
405
|
{
|
|
406
406
|
id: 'stage-3',
|
|
407
407
|
order: 2,
|
|
408
408
|
name: 'Final Qualification',
|
|
409
|
-
|
|
409
|
+
filterLogic: 'AND',
|
|
410
410
|
rules: [
|
|
411
|
-
{
|
|
411
|
+
{ fieldPath: 'tags', operator: 'has_all', value: ['enterprise_size', 'engaged'] },
|
|
412
412
|
],
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
413
|
+
matchAction: 'output',
|
|
414
|
+
noMatchAction: 'continue',
|
|
415
|
+
matchTags: ['hot_lead'],
|
|
416
416
|
},
|
|
417
417
|
],
|
|
418
|
-
|
|
419
|
-
|
|
418
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
419
|
+
updatedAt: '2024-01-15T10:30:00Z',
|
|
420
420
|
},
|
|
421
421
|
latestRun: {
|
|
422
422
|
...completedRun,
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
423
|
+
totalInput: 12500,
|
|
424
|
+
totalMatched: 342,
|
|
425
|
+
totalExcluded: 12158,
|
|
426
426
|
},
|
|
427
427
|
},
|
|
428
428
|
};
|
|
@@ -434,51 +434,51 @@ export const GitHubIssueFunnel: Story = {
|
|
|
434
434
|
name: 'GitHub Issue Priority Triage',
|
|
435
435
|
description: 'Filters GitHub issues to identify high-priority items requiring immediate attention.',
|
|
436
436
|
status: 'active',
|
|
437
|
-
|
|
437
|
+
inputType: 'any',
|
|
438
438
|
stages: [
|
|
439
439
|
{
|
|
440
440
|
id: 'stage-1',
|
|
441
441
|
order: 0,
|
|
442
442
|
name: 'Filter PRs',
|
|
443
|
-
|
|
443
|
+
filterLogic: 'AND',
|
|
444
444
|
rules: [
|
|
445
|
-
{
|
|
445
|
+
{ fieldPath: 'is_pull_request', operator: 'is_false', value: null },
|
|
446
446
|
],
|
|
447
|
-
|
|
448
|
-
|
|
447
|
+
matchAction: 'continue',
|
|
448
|
+
noMatchAction: 'exclude',
|
|
449
449
|
},
|
|
450
450
|
{
|
|
451
451
|
id: 'stage-2',
|
|
452
452
|
order: 1,
|
|
453
453
|
name: 'Priority Labels',
|
|
454
|
-
|
|
454
|
+
filterLogic: 'OR',
|
|
455
455
|
rules: [
|
|
456
|
-
{
|
|
456
|
+
{ fieldPath: 'labels', operator: 'has_any', value: ['bug', 'security'] },
|
|
457
457
|
],
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
458
|
+
matchAction: 'tag_continue',
|
|
459
|
+
noMatchAction: 'continue',
|
|
460
|
+
matchTags: ['high_priority'],
|
|
461
461
|
},
|
|
462
462
|
{
|
|
463
463
|
id: 'stage-3',
|
|
464
464
|
order: 2,
|
|
465
465
|
name: 'Community Interest',
|
|
466
|
-
|
|
466
|
+
filterLogic: 'AND',
|
|
467
467
|
rules: [
|
|
468
|
-
{
|
|
468
|
+
{ fieldPath: 'comments_count', operator: 'gte', value: 5 },
|
|
469
469
|
],
|
|
470
|
-
|
|
471
|
-
|
|
470
|
+
matchAction: 'output',
|
|
471
|
+
noMatchAction: 'output',
|
|
472
472
|
},
|
|
473
473
|
],
|
|
474
|
-
|
|
475
|
-
|
|
474
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
475
|
+
updatedAt: '2024-01-15T10:30:00Z',
|
|
476
476
|
},
|
|
477
477
|
latestRun: {
|
|
478
478
|
...completedRun,
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
479
|
+
totalInput: 1847,
|
|
480
|
+
totalMatched: 92,
|
|
481
|
+
totalExcluded: 1755,
|
|
482
482
|
},
|
|
483
483
|
},
|
|
484
484
|
};
|
|
@@ -23,37 +23,37 @@ function createFunnel(overrides?: Partial<Funnel>): Funnel {
|
|
|
23
23
|
name: 'Test Funnel',
|
|
24
24
|
description: 'Test funnel description',
|
|
25
25
|
status: 'active',
|
|
26
|
-
|
|
26
|
+
inputType: 'any',
|
|
27
27
|
stages: [
|
|
28
28
|
{
|
|
29
29
|
id: 'stage-1',
|
|
30
30
|
order: 0,
|
|
31
31
|
name: 'Stage 1',
|
|
32
32
|
description: 'First stage',
|
|
33
|
-
|
|
33
|
+
filterLogic: 'AND',
|
|
34
34
|
rules: [
|
|
35
|
-
{
|
|
35
|
+
{ fieldPath: 'name', operator: 'eq', value: 'test' }
|
|
36
36
|
],
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
matchAction: 'continue',
|
|
38
|
+
noMatchAction: 'exclude',
|
|
39
39
|
},
|
|
40
40
|
{
|
|
41
41
|
id: 'stage-2',
|
|
42
42
|
order: 1,
|
|
43
43
|
name: 'Stage 2',
|
|
44
44
|
description: 'Second stage',
|
|
45
|
-
|
|
45
|
+
filterLogic: 'OR',
|
|
46
46
|
rules: [
|
|
47
|
-
{
|
|
48
|
-
{
|
|
49
|
-
{
|
|
47
|
+
{ fieldPath: 'value', operator: 'gt', value: 100 },
|
|
48
|
+
{ fieldPath: 'type', operator: 'in', value: ['A', 'B'] },
|
|
49
|
+
{ fieldPath: 'active', operator: 'is_true', value: null },
|
|
50
50
|
],
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
matchAction: 'output',
|
|
52
|
+
noMatchAction: 'exclude',
|
|
53
53
|
},
|
|
54
54
|
],
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
createdAt: '2024-01-01T00:00:00Z',
|
|
56
|
+
updatedAt: '2024-01-01T00:00:00Z',
|
|
57
57
|
...overrides,
|
|
58
58
|
};
|
|
59
59
|
}
|
|
@@ -61,17 +61,17 @@ function createFunnel(overrides?: Partial<Funnel>): Funnel {
|
|
|
61
61
|
function createFunnelRun(overrides?: Partial<FunnelRun>): FunnelRun {
|
|
62
62
|
return {
|
|
63
63
|
id: 'run-1',
|
|
64
|
-
|
|
64
|
+
funnelId: 'funnel-1',
|
|
65
65
|
status: 'completed',
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
66
|
+
triggerType: 'manual',
|
|
67
|
+
startedAt: '2024-01-01T00:00:00Z',
|
|
68
|
+
completedAt: '2024-01-01T00:01:00Z',
|
|
69
|
+
durationMs: 60000,
|
|
70
|
+
totalInput: 83061,
|
|
71
|
+
totalMatched: 235,
|
|
72
|
+
totalExcluded: 82826,
|
|
73
|
+
totalTagged: 235,
|
|
74
|
+
stageStats: {},
|
|
75
75
|
...overrides,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
@@ -99,14 +99,14 @@ describe('FunnelCard', () => {
|
|
|
99
99
|
|
|
100
100
|
expect(run.id).toBe('run-1');
|
|
101
101
|
expect(run.status).toBe('completed');
|
|
102
|
-
expect(run.
|
|
103
|
-
expect(run.
|
|
102
|
+
expect(run.totalInput).toBe(83061);
|
|
103
|
+
expect(run.totalMatched).toBe(235);
|
|
104
104
|
});
|
|
105
105
|
|
|
106
106
|
it('creates funnel run with overrides', () => {
|
|
107
|
-
const run = createFunnelRun({
|
|
107
|
+
const run = createFunnelRun({ totalMatched: 1000 });
|
|
108
108
|
|
|
109
|
-
expect(run.
|
|
109
|
+
expect(run.totalMatched).toBe(1000);
|
|
110
110
|
});
|
|
111
111
|
});
|
|
112
112
|
|
|
@@ -122,10 +122,10 @@ describe('FunnelCard', () => {
|
|
|
122
122
|
id: `stage-${i}`,
|
|
123
123
|
order: i,
|
|
124
124
|
name: `Stage ${i + 1}`,
|
|
125
|
-
|
|
126
|
-
rules: [{
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
filterLogic: 'AND' as const,
|
|
126
|
+
rules: [{ fieldPath: 'x', operator: 'eq' as const, value: i }],
|
|
127
|
+
matchAction: 'continue' as const,
|
|
128
|
+
noMatchAction: 'exclude' as const,
|
|
129
129
|
}));
|
|
130
130
|
const funnel = createFunnel({ stages });
|
|
131
131
|
|
|
@@ -147,21 +147,21 @@ describe('FunnelCard', () => {
|
|
|
147
147
|
describe('Run Stats Calculation', () => {
|
|
148
148
|
it('calculates match percentage correctly', () => {
|
|
149
149
|
const run = createFunnelRun();
|
|
150
|
-
const percentage = (run.
|
|
150
|
+
const percentage = (run.totalMatched / run.totalInput) * 100;
|
|
151
151
|
|
|
152
152
|
expect(percentage).toBeCloseTo(0.28, 2); // 235/83061 ≈ 0.28%
|
|
153
153
|
});
|
|
154
154
|
|
|
155
155
|
it('handles zero input', () => {
|
|
156
|
-
const run = createFunnelRun({
|
|
157
|
-
const percentage = run.
|
|
156
|
+
const run = createFunnelRun({ totalInput: 0, totalMatched: 0 });
|
|
157
|
+
const percentage = run.totalInput > 0 ? (run.totalMatched / run.totalInput) * 100 : 0;
|
|
158
158
|
|
|
159
159
|
expect(percentage).toBe(0);
|
|
160
160
|
});
|
|
161
161
|
|
|
162
162
|
it('handles 100% match rate', () => {
|
|
163
|
-
const run = createFunnelRun({
|
|
164
|
-
const percentage = (run.
|
|
163
|
+
const run = createFunnelRun({ totalInput: 1000, totalMatched: 1000, totalExcluded: 0 });
|
|
164
|
+
const percentage = (run.totalMatched / run.totalInput) * 100;
|
|
165
165
|
|
|
166
166
|
expect(percentage).toBe(100);
|
|
167
167
|
});
|
|
@@ -182,10 +182,10 @@ describe('FunnelCard', () => {
|
|
|
182
182
|
id: 'stage-1',
|
|
183
183
|
order: 0,
|
|
184
184
|
name: 'Empty Stage',
|
|
185
|
-
|
|
185
|
+
filterLogic: 'AND',
|
|
186
186
|
rules: [],
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
matchAction: 'continue',
|
|
188
|
+
noMatchAction: 'exclude',
|
|
189
189
|
},
|
|
190
190
|
],
|
|
191
191
|
});
|
|
@@ -199,14 +199,14 @@ describe('FunnelCard', () => {
|
|
|
199
199
|
const run = createFunnelRun({ status: 'completed' });
|
|
200
200
|
|
|
201
201
|
expect(run.status).toBe('completed');
|
|
202
|
-
expect(run.
|
|
202
|
+
expect(run.completedAt).toBeDefined();
|
|
203
203
|
});
|
|
204
204
|
|
|
205
205
|
it('validates running state', () => {
|
|
206
|
-
const run = createFunnelRun({ status: 'running',
|
|
206
|
+
const run = createFunnelRun({ status: 'running', completedAt: undefined });
|
|
207
207
|
|
|
208
208
|
expect(run.status).toBe('running');
|
|
209
|
-
expect(run.
|
|
209
|
+
expect(run.completedAt).toBeUndefined();
|
|
210
210
|
});
|
|
211
211
|
|
|
212
212
|
it('validates failed run', () => {
|
|
@@ -234,19 +234,19 @@ describe('FunnelCard', () => {
|
|
|
234
234
|
|
|
235
235
|
it('handles large numbers in stats', () => {
|
|
236
236
|
const run = createFunnelRun({
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
237
|
+
totalInput: 10000000,
|
|
238
|
+
totalMatched: 500000,
|
|
239
|
+
totalExcluded: 9500000,
|
|
240
240
|
});
|
|
241
241
|
|
|
242
|
-
expect(run.
|
|
243
|
-
expect(run.
|
|
242
|
+
expect(run.totalInput).toBe(10000000);
|
|
243
|
+
expect(run.totalMatched + run.totalExcluded).toBe(run.totalInput);
|
|
244
244
|
});
|
|
245
245
|
|
|
246
246
|
it('validates stats add up correctly', () => {
|
|
247
247
|
const run = createFunnelRun();
|
|
248
248
|
|
|
249
|
-
expect(run.
|
|
249
|
+
expect(run.totalMatched + run.totalExcluded).toBe(run.totalInput);
|
|
250
250
|
});
|
|
251
251
|
});
|
|
252
252
|
});
|