@usertour/helpers 0.0.32 → 0.0.34
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/dist/__tests__/attribute.test.cjs +477 -40
- package/dist/__tests__/attribute.test.js +465 -29
- package/dist/__tests__/condition.test.cjs +13 -12
- package/dist/__tests__/condition.test.js +2 -2
- package/dist/{chunk-P46FJFKP.js → chunk-7JXEY4A2.js} +13 -12
- package/dist/{chunk-VBHUPKP7.js → chunk-A4KMGXB3.js} +1 -1
- package/dist/conditions/attribute.cjs +13 -12
- package/dist/conditions/attribute.js +1 -1
- package/dist/conditions/condition.cjs +13 -12
- package/dist/conditions/condition.js +2 -2
- package/dist/conditions/index.cjs +13 -12
- package/dist/conditions/index.js +2 -2
- package/dist/index.cjs +13 -12
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
evaluateAttributeCondition,
|
|
3
3
|
evaluateFilterConditions
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-7JXEY4A2.js";
|
|
5
5
|
import "../chunk-XEO3YXBM.js";
|
|
6
6
|
|
|
7
7
|
// src/__tests__/attribute.test.ts
|
|
@@ -34,6 +34,12 @@ var testAttributes = [
|
|
|
34
34
|
dataType: BizAttributeTypes.List,
|
|
35
35
|
bizType: AttributeBizTypes.User
|
|
36
36
|
},
|
|
37
|
+
{
|
|
38
|
+
id: "tags-attr",
|
|
39
|
+
codeName: "tags",
|
|
40
|
+
dataType: BizAttributeTypes.List,
|
|
41
|
+
bizType: AttributeBizTypes.User
|
|
42
|
+
},
|
|
37
43
|
{
|
|
38
44
|
id: "signUpDate-attr",
|
|
39
45
|
codeName: "signUpDate",
|
|
@@ -46,6 +52,12 @@ var testAttributes = [
|
|
|
46
52
|
dataType: BizAttributeTypes.Number,
|
|
47
53
|
bizType: AttributeBizTypes.User
|
|
48
54
|
},
|
|
55
|
+
{
|
|
56
|
+
id: "sdsdd-attr",
|
|
57
|
+
codeName: "sdsdd",
|
|
58
|
+
dataType: BizAttributeTypes.Number,
|
|
59
|
+
bizType: AttributeBizTypes.User
|
|
60
|
+
},
|
|
49
61
|
// Company attributes
|
|
50
62
|
{
|
|
51
63
|
id: "company-name-attr",
|
|
@@ -78,8 +90,10 @@ var testUserAttributes = {
|
|
|
78
90
|
age: 25,
|
|
79
91
|
isPremium: true,
|
|
80
92
|
roles: ["admin", "user"],
|
|
93
|
+
tags: [123, 456],
|
|
81
94
|
signUpDate: "2024-01-15T10:30:00Z",
|
|
82
|
-
score: 85.5
|
|
95
|
+
score: 85.5,
|
|
96
|
+
sdsdd: 101
|
|
83
97
|
};
|
|
84
98
|
var testCompanyAttributes = {
|
|
85
99
|
companyName: "Example Corp",
|
|
@@ -352,6 +366,229 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
352
366
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
353
367
|
});
|
|
354
368
|
});
|
|
369
|
+
describe("Number conditions with string values", () => {
|
|
370
|
+
test('should evaluate "is" condition when actualValue is number and expectedValue is string', () => {
|
|
371
|
+
const condition = [
|
|
372
|
+
{
|
|
373
|
+
id: "number-string-condition-1",
|
|
374
|
+
type: "condition",
|
|
375
|
+
operators: "and",
|
|
376
|
+
data: {
|
|
377
|
+
logic: "is",
|
|
378
|
+
value: "101",
|
|
379
|
+
attrId: "sdsdd-attr"
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
];
|
|
383
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
384
|
+
});
|
|
385
|
+
test('should evaluate "is" condition when actualValue is string and expectedValue is number', () => {
|
|
386
|
+
const userAttributesWithStringNumber = {
|
|
387
|
+
...testUserAttributes,
|
|
388
|
+
sdsdd: "101"
|
|
389
|
+
};
|
|
390
|
+
const condition = [
|
|
391
|
+
{
|
|
392
|
+
id: "number-string-condition-2",
|
|
393
|
+
type: "condition",
|
|
394
|
+
operators: "and",
|
|
395
|
+
data: {
|
|
396
|
+
logic: "is",
|
|
397
|
+
value: 101,
|
|
398
|
+
attrId: "sdsdd-attr"
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
];
|
|
402
|
+
expect(
|
|
403
|
+
evaluateFilterConditions(condition, {
|
|
404
|
+
...defaultOptions,
|
|
405
|
+
userAttributes: userAttributesWithStringNumber
|
|
406
|
+
})
|
|
407
|
+
).toBe(true);
|
|
408
|
+
});
|
|
409
|
+
test('should evaluate "is" condition when both actualValue and expectedValue are strings', () => {
|
|
410
|
+
const userAttributesWithStringNumber = {
|
|
411
|
+
...testUserAttributes,
|
|
412
|
+
sdsdd: "101"
|
|
413
|
+
};
|
|
414
|
+
const condition = [
|
|
415
|
+
{
|
|
416
|
+
id: "number-string-condition-3",
|
|
417
|
+
type: "condition",
|
|
418
|
+
operators: "and",
|
|
419
|
+
data: {
|
|
420
|
+
logic: "is",
|
|
421
|
+
value: "101",
|
|
422
|
+
attrId: "sdsdd-attr"
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
];
|
|
426
|
+
expect(
|
|
427
|
+
evaluateFilterConditions(condition, {
|
|
428
|
+
...defaultOptions,
|
|
429
|
+
userAttributes: userAttributesWithStringNumber
|
|
430
|
+
})
|
|
431
|
+
).toBe(true);
|
|
432
|
+
});
|
|
433
|
+
test('should evaluate "not" condition when actualValue is number and expectedValue is string', () => {
|
|
434
|
+
const condition = [
|
|
435
|
+
{
|
|
436
|
+
id: "number-string-condition-4",
|
|
437
|
+
type: "condition",
|
|
438
|
+
operators: "and",
|
|
439
|
+
data: {
|
|
440
|
+
logic: "not",
|
|
441
|
+
value: "102",
|
|
442
|
+
attrId: "sdsdd-attr"
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
];
|
|
446
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
447
|
+
});
|
|
448
|
+
test('should evaluate "isLessThan" condition when expectedValue is string', () => {
|
|
449
|
+
const condition = [
|
|
450
|
+
{
|
|
451
|
+
id: "number-string-condition-5",
|
|
452
|
+
type: "condition",
|
|
453
|
+
operators: "and",
|
|
454
|
+
data: {
|
|
455
|
+
logic: "isLessThan",
|
|
456
|
+
value: "102",
|
|
457
|
+
attrId: "sdsdd-attr"
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
];
|
|
461
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
462
|
+
});
|
|
463
|
+
test('should evaluate "isGreaterThan" condition when expectedValue is string', () => {
|
|
464
|
+
const condition = [
|
|
465
|
+
{
|
|
466
|
+
id: "number-string-condition-6",
|
|
467
|
+
type: "condition",
|
|
468
|
+
operators: "and",
|
|
469
|
+
data: {
|
|
470
|
+
logic: "isGreaterThan",
|
|
471
|
+
value: "100",
|
|
472
|
+
attrId: "sdsdd-attr"
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
];
|
|
476
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
477
|
+
});
|
|
478
|
+
test('should evaluate "between" condition when value and value2 are strings', () => {
|
|
479
|
+
const condition = [
|
|
480
|
+
{
|
|
481
|
+
id: "number-string-condition-7",
|
|
482
|
+
type: "condition",
|
|
483
|
+
operators: "and",
|
|
484
|
+
data: {
|
|
485
|
+
logic: "between",
|
|
486
|
+
value: "100",
|
|
487
|
+
value2: "103",
|
|
488
|
+
attrId: "sdsdd-attr"
|
|
489
|
+
}
|
|
490
|
+
}
|
|
491
|
+
];
|
|
492
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
493
|
+
});
|
|
494
|
+
test('should evaluate "between" condition when actualValue is string and values are strings', () => {
|
|
495
|
+
const userAttributesWithStringNumber = {
|
|
496
|
+
...testUserAttributes,
|
|
497
|
+
sdsdd: "101"
|
|
498
|
+
};
|
|
499
|
+
const condition = [
|
|
500
|
+
{
|
|
501
|
+
id: "number-string-condition-8",
|
|
502
|
+
type: "condition",
|
|
503
|
+
operators: "and",
|
|
504
|
+
data: {
|
|
505
|
+
logic: "between",
|
|
506
|
+
value: "100",
|
|
507
|
+
value2: "103",
|
|
508
|
+
attrId: "sdsdd-attr"
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
];
|
|
512
|
+
expect(
|
|
513
|
+
evaluateFilterConditions(condition, {
|
|
514
|
+
...defaultOptions,
|
|
515
|
+
userAttributes: userAttributesWithStringNumber
|
|
516
|
+
})
|
|
517
|
+
).toBe(true);
|
|
518
|
+
});
|
|
519
|
+
test("should return false when actualValue is NaN", () => {
|
|
520
|
+
const userAttributesWithNaN = {
|
|
521
|
+
...testUserAttributes,
|
|
522
|
+
sdsdd: "not-a-number"
|
|
523
|
+
};
|
|
524
|
+
const condition = [
|
|
525
|
+
{
|
|
526
|
+
id: "number-string-condition-9",
|
|
527
|
+
type: "condition",
|
|
528
|
+
operators: "and",
|
|
529
|
+
data: {
|
|
530
|
+
logic: "is",
|
|
531
|
+
value: 101,
|
|
532
|
+
attrId: "sdsdd-attr"
|
|
533
|
+
}
|
|
534
|
+
}
|
|
535
|
+
];
|
|
536
|
+
expect(
|
|
537
|
+
evaluateFilterConditions(condition, {
|
|
538
|
+
...defaultOptions,
|
|
539
|
+
userAttributes: userAttributesWithNaN
|
|
540
|
+
})
|
|
541
|
+
).toBe(false);
|
|
542
|
+
});
|
|
543
|
+
test("should handle decimal string values correctly", () => {
|
|
544
|
+
const userAttributesWithDecimal = {
|
|
545
|
+
...testUserAttributes,
|
|
546
|
+
score: "85.5"
|
|
547
|
+
};
|
|
548
|
+
const condition = [
|
|
549
|
+
{
|
|
550
|
+
id: "number-string-condition-10",
|
|
551
|
+
type: "condition",
|
|
552
|
+
operators: "and",
|
|
553
|
+
data: {
|
|
554
|
+
logic: "is",
|
|
555
|
+
value: "85.5",
|
|
556
|
+
attrId: "score-attr"
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
];
|
|
560
|
+
expect(
|
|
561
|
+
evaluateFilterConditions(condition, {
|
|
562
|
+
...defaultOptions,
|
|
563
|
+
userAttributes: userAttributesWithDecimal
|
|
564
|
+
})
|
|
565
|
+
).toBe(true);
|
|
566
|
+
});
|
|
567
|
+
test("should handle negative string values correctly", () => {
|
|
568
|
+
const userAttributesWithNegative = {
|
|
569
|
+
...testUserAttributes,
|
|
570
|
+
sdsdd: "-50"
|
|
571
|
+
};
|
|
572
|
+
const condition = [
|
|
573
|
+
{
|
|
574
|
+
id: "number-string-condition-11",
|
|
575
|
+
type: "condition",
|
|
576
|
+
operators: "and",
|
|
577
|
+
data: {
|
|
578
|
+
logic: "isLessThan",
|
|
579
|
+
value: "0",
|
|
580
|
+
attrId: "sdsdd-attr"
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
];
|
|
584
|
+
expect(
|
|
585
|
+
evaluateFilterConditions(condition, {
|
|
586
|
+
...defaultOptions,
|
|
587
|
+
userAttributes: userAttributesWithNegative
|
|
588
|
+
})
|
|
589
|
+
).toBe(true);
|
|
590
|
+
});
|
|
591
|
+
});
|
|
355
592
|
describe("Boolean conditions (4 cases)", () => {
|
|
356
593
|
test('should evaluate "true" condition correctly', () => {
|
|
357
594
|
const condition = [
|
|
@@ -441,35 +678,234 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
441
678
|
];
|
|
442
679
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
443
680
|
});
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
681
|
+
describe("notIncludesAtLeastOne condition", () => {
|
|
682
|
+
test("should return true when at least one value is not included (single value not included)", () => {
|
|
683
|
+
const condition = [
|
|
684
|
+
{
|
|
685
|
+
id: "condition-24",
|
|
686
|
+
type: "condition",
|
|
687
|
+
operators: "and",
|
|
688
|
+
data: {
|
|
689
|
+
logic: "notIncludesAtLeastOne",
|
|
690
|
+
listValues: ["guest"],
|
|
691
|
+
attrId: "roles-attr"
|
|
692
|
+
}
|
|
454
693
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
694
|
+
];
|
|
695
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
696
|
+
});
|
|
697
|
+
test("should return true when at least one value is not included (partial values not included)", () => {
|
|
698
|
+
const condition = [
|
|
699
|
+
{
|
|
700
|
+
id: "condition-24-2",
|
|
701
|
+
type: "condition",
|
|
702
|
+
operators: "and",
|
|
703
|
+
data: {
|
|
704
|
+
logic: "notIncludesAtLeastOne",
|
|
705
|
+
listValues: ["admin", "guest"],
|
|
706
|
+
attrId: "roles-attr"
|
|
707
|
+
}
|
|
469
708
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
709
|
+
];
|
|
710
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
711
|
+
});
|
|
712
|
+
test("should return true when all values are not included", () => {
|
|
713
|
+
const condition = [
|
|
714
|
+
{
|
|
715
|
+
id: "condition-24-3",
|
|
716
|
+
type: "condition",
|
|
717
|
+
operators: "and",
|
|
718
|
+
data: {
|
|
719
|
+
logic: "notIncludesAtLeastOne",
|
|
720
|
+
listValues: ["guest", "visitor"],
|
|
721
|
+
attrId: "roles-attr"
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
];
|
|
725
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
726
|
+
});
|
|
727
|
+
test("should return false when all values are included", () => {
|
|
728
|
+
const condition = [
|
|
729
|
+
{
|
|
730
|
+
id: "condition-24-4",
|
|
731
|
+
type: "condition",
|
|
732
|
+
operators: "and",
|
|
733
|
+
data: {
|
|
734
|
+
logic: "notIncludesAtLeastOne",
|
|
735
|
+
listValues: ["admin", "user"],
|
|
736
|
+
attrId: "roles-attr"
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
];
|
|
740
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
741
|
+
});
|
|
742
|
+
test("should return false when single value is included", () => {
|
|
743
|
+
const condition = [
|
|
744
|
+
{
|
|
745
|
+
id: "condition-24-5",
|
|
746
|
+
type: "condition",
|
|
747
|
+
operators: "and",
|
|
748
|
+
data: {
|
|
749
|
+
logic: "notIncludesAtLeastOne",
|
|
750
|
+
listValues: ["admin"],
|
|
751
|
+
attrId: "roles-attr"
|
|
752
|
+
}
|
|
753
|
+
}
|
|
754
|
+
];
|
|
755
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
756
|
+
});
|
|
757
|
+
test("should return true for numeric list when at least one value is not included", () => {
|
|
758
|
+
const condition = [
|
|
759
|
+
{
|
|
760
|
+
id: "condition-24-6",
|
|
761
|
+
type: "condition",
|
|
762
|
+
operators: "and",
|
|
763
|
+
data: {
|
|
764
|
+
logic: "notIncludesAtLeastOne",
|
|
765
|
+
listValues: [123, 444],
|
|
766
|
+
attrId: "tags-attr"
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
];
|
|
770
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
771
|
+
});
|
|
772
|
+
test("should return false for numeric list when all values are included", () => {
|
|
773
|
+
const condition = [
|
|
774
|
+
{
|
|
775
|
+
id: "condition-24-7",
|
|
776
|
+
type: "condition",
|
|
777
|
+
operators: "and",
|
|
778
|
+
data: {
|
|
779
|
+
logic: "notIncludesAtLeastOne",
|
|
780
|
+
listValues: [123, 456],
|
|
781
|
+
attrId: "tags-attr"
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
];
|
|
785
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
786
|
+
});
|
|
787
|
+
});
|
|
788
|
+
describe("notIncludesAll condition", () => {
|
|
789
|
+
test("should return true when all values are not included", () => {
|
|
790
|
+
const condition = [
|
|
791
|
+
{
|
|
792
|
+
id: "condition-25",
|
|
793
|
+
type: "condition",
|
|
794
|
+
operators: "and",
|
|
795
|
+
data: {
|
|
796
|
+
logic: "notIncludesAll",
|
|
797
|
+
listValues: ["guest", "visitor"],
|
|
798
|
+
attrId: "roles-attr"
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
];
|
|
802
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
803
|
+
});
|
|
804
|
+
test("should return true when single value is not included", () => {
|
|
805
|
+
const condition = [
|
|
806
|
+
{
|
|
807
|
+
id: "condition-25-2",
|
|
808
|
+
type: "condition",
|
|
809
|
+
operators: "and",
|
|
810
|
+
data: {
|
|
811
|
+
logic: "notIncludesAll",
|
|
812
|
+
listValues: ["guest"],
|
|
813
|
+
attrId: "roles-attr"
|
|
814
|
+
}
|
|
815
|
+
}
|
|
816
|
+
];
|
|
817
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
818
|
+
});
|
|
819
|
+
test("should return false when at least one value is included", () => {
|
|
820
|
+
const condition = [
|
|
821
|
+
{
|
|
822
|
+
id: "condition-25-3",
|
|
823
|
+
type: "condition",
|
|
824
|
+
operators: "and",
|
|
825
|
+
data: {
|
|
826
|
+
logic: "notIncludesAll",
|
|
827
|
+
listValues: ["admin", "guest"],
|
|
828
|
+
attrId: "roles-attr"
|
|
829
|
+
}
|
|
830
|
+
}
|
|
831
|
+
];
|
|
832
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
833
|
+
});
|
|
834
|
+
test("should return false when all values are included", () => {
|
|
835
|
+
const condition = [
|
|
836
|
+
{
|
|
837
|
+
id: "condition-25-4",
|
|
838
|
+
type: "condition",
|
|
839
|
+
operators: "and",
|
|
840
|
+
data: {
|
|
841
|
+
logic: "notIncludesAll",
|
|
842
|
+
listValues: ["admin", "user"],
|
|
843
|
+
attrId: "roles-attr"
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
];
|
|
847
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
848
|
+
});
|
|
849
|
+
test("should return false when single value is included", () => {
|
|
850
|
+
const condition = [
|
|
851
|
+
{
|
|
852
|
+
id: "condition-25-5",
|
|
853
|
+
type: "condition",
|
|
854
|
+
operators: "and",
|
|
855
|
+
data: {
|
|
856
|
+
logic: "notIncludesAll",
|
|
857
|
+
listValues: ["admin"],
|
|
858
|
+
attrId: "roles-attr"
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
];
|
|
862
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
863
|
+
});
|
|
864
|
+
test("should return true for numeric list when all values are not included", () => {
|
|
865
|
+
const condition = [
|
|
866
|
+
{
|
|
867
|
+
id: "condition-25-6",
|
|
868
|
+
type: "condition",
|
|
869
|
+
operators: "and",
|
|
870
|
+
data: {
|
|
871
|
+
logic: "notIncludesAll",
|
|
872
|
+
listValues: [1234, 789],
|
|
873
|
+
attrId: "tags-attr"
|
|
874
|
+
}
|
|
875
|
+
}
|
|
876
|
+
];
|
|
877
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
878
|
+
});
|
|
879
|
+
test("should return false for numeric list when at least one value is included", () => {
|
|
880
|
+
const condition = [
|
|
881
|
+
{
|
|
882
|
+
id: "condition-25-7",
|
|
883
|
+
type: "condition",
|
|
884
|
+
operators: "and",
|
|
885
|
+
data: {
|
|
886
|
+
logic: "notIncludesAll",
|
|
887
|
+
listValues: [123, 444],
|
|
888
|
+
attrId: "tags-attr"
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
];
|
|
892
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
893
|
+
});
|
|
894
|
+
test("should return false for numeric list when all values are included", () => {
|
|
895
|
+
const condition = [
|
|
896
|
+
{
|
|
897
|
+
id: "condition-25-8",
|
|
898
|
+
type: "condition",
|
|
899
|
+
operators: "and",
|
|
900
|
+
data: {
|
|
901
|
+
logic: "notIncludesAll",
|
|
902
|
+
listValues: [123, 456],
|
|
903
|
+
attrId: "tags-attr"
|
|
904
|
+
}
|
|
905
|
+
}
|
|
906
|
+
];
|
|
907
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
908
|
+
});
|
|
473
909
|
});
|
|
474
910
|
test('should evaluate "empty" condition correctly', () => {
|
|
475
911
|
const condition = [
|
|
@@ -210,26 +210,27 @@ function evaluateStringCondition(logic, actualValue, expectedValue) {
|
|
|
210
210
|
}
|
|
211
211
|
}
|
|
212
212
|
function evaluateNumberCondition(logic, actualValue, expectedValue, expectedValue2) {
|
|
213
|
-
const
|
|
214
|
-
const
|
|
215
|
-
|
|
213
|
+
const numActualValue = Number(actualValue);
|
|
214
|
+
const numExpectedValue = Number(expectedValue);
|
|
215
|
+
const numExpectedValue2 = Number(expectedValue2);
|
|
216
|
+
if (Number.isNaN(numActualValue)) {
|
|
216
217
|
return false;
|
|
217
218
|
}
|
|
218
219
|
switch (logic) {
|
|
219
220
|
case "is":
|
|
220
|
-
return
|
|
221
|
+
return numActualValue === numExpectedValue;
|
|
221
222
|
case "not":
|
|
222
|
-
return
|
|
223
|
+
return numActualValue !== numExpectedValue;
|
|
223
224
|
case "isLessThan":
|
|
224
|
-
return
|
|
225
|
+
return numActualValue < numExpectedValue;
|
|
225
226
|
case "isLessThanOrEqualTo":
|
|
226
|
-
return
|
|
227
|
+
return numActualValue <= numExpectedValue;
|
|
227
228
|
case "isGreaterThan":
|
|
228
|
-
return
|
|
229
|
+
return numActualValue > numExpectedValue;
|
|
229
230
|
case "isGreaterThanOrEqualTo":
|
|
230
|
-
return
|
|
231
|
+
return numActualValue >= numExpectedValue;
|
|
231
232
|
case "between":
|
|
232
|
-
return
|
|
233
|
+
return numActualValue >= numExpectedValue && numActualValue <= numExpectedValue2;
|
|
233
234
|
case "empty":
|
|
234
235
|
return actualValue === null || actualValue === void 0 || actualValue === "";
|
|
235
236
|
case "any":
|
|
@@ -276,9 +277,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
276
277
|
case "includesAll":
|
|
277
278
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
278
279
|
case "notIncludesAtLeastOne":
|
|
279
|
-
return
|
|
280
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
280
281
|
case "notIncludesAll":
|
|
281
|
-
return
|
|
282
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
282
283
|
default:
|
|
283
284
|
return false;
|
|
284
285
|
}
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
evaluateRulesConditions,
|
|
3
3
|
filterConditionsByType,
|
|
4
4
|
isConditionsActived
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-A4KMGXB3.js";
|
|
6
6
|
import "../chunk-YYIGUZNZ.js";
|
|
7
7
|
import "../chunk-PAESAL23.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-7JXEY4A2.js";
|
|
9
9
|
import "../chunk-CEK3SCQO.js";
|
|
10
10
|
import "../chunk-3KG2HTZ3.js";
|
|
11
11
|
import "../chunk-XEO3YXBM.js";
|
|
@@ -108,26 +108,27 @@ function evaluateStringCondition(logic, actualValue, expectedValue) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
function evaluateNumberCondition(logic, actualValue, expectedValue, expectedValue2) {
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
|
|
111
|
+
const numActualValue = Number(actualValue);
|
|
112
|
+
const numExpectedValue = Number(expectedValue);
|
|
113
|
+
const numExpectedValue2 = Number(expectedValue2);
|
|
114
|
+
if (Number.isNaN(numActualValue)) {
|
|
114
115
|
return false;
|
|
115
116
|
}
|
|
116
117
|
switch (logic) {
|
|
117
118
|
case "is":
|
|
118
|
-
return
|
|
119
|
+
return numActualValue === numExpectedValue;
|
|
119
120
|
case "not":
|
|
120
|
-
return
|
|
121
|
+
return numActualValue !== numExpectedValue;
|
|
121
122
|
case "isLessThan":
|
|
122
|
-
return
|
|
123
|
+
return numActualValue < numExpectedValue;
|
|
123
124
|
case "isLessThanOrEqualTo":
|
|
124
|
-
return
|
|
125
|
+
return numActualValue <= numExpectedValue;
|
|
125
126
|
case "isGreaterThan":
|
|
126
|
-
return
|
|
127
|
+
return numActualValue > numExpectedValue;
|
|
127
128
|
case "isGreaterThanOrEqualTo":
|
|
128
|
-
return
|
|
129
|
+
return numActualValue >= numExpectedValue;
|
|
129
130
|
case "between":
|
|
130
|
-
return
|
|
131
|
+
return numActualValue >= numExpectedValue && numActualValue <= numExpectedValue2;
|
|
131
132
|
case "empty":
|
|
132
133
|
return actualValue === null || actualValue === void 0 || actualValue === "";
|
|
133
134
|
case "any":
|
|
@@ -174,9 +175,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
174
175
|
case "includesAll":
|
|
175
176
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
176
177
|
case "notIncludesAtLeastOne":
|
|
177
|
-
return
|
|
178
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
178
179
|
case "notIncludesAll":
|
|
179
|
-
return
|
|
180
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
180
181
|
default:
|
|
181
182
|
return false;
|
|
182
183
|
}
|