@usertour/helpers 0.0.32 → 0.0.33
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 +235 -29
- package/dist/__tests__/attribute.test.js +234 -28
- package/dist/__tests__/condition.test.cjs +2 -2
- package/dist/__tests__/condition.test.js +2 -2
- package/dist/{chunk-P46FJFKP.js → chunk-E2APTIR7.js} +2 -2
- package/dist/{chunk-VBHUPKP7.js → chunk-YZQBWYCU.js} +1 -1
- package/dist/conditions/attribute.cjs +2 -2
- package/dist/conditions/attribute.js +1 -1
- package/dist/conditions/condition.cjs +2 -2
- package/dist/conditions/condition.js +2 -2
- package/dist/conditions/index.cjs +2 -2
- package/dist/conditions/index.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
|
@@ -176,9 +176,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
176
176
|
case "includesAll":
|
|
177
177
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
178
178
|
case "notIncludesAtLeastOne":
|
|
179
|
-
return
|
|
179
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
180
180
|
case "notIncludesAll":
|
|
181
|
-
return
|
|
181
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
182
182
|
default:
|
|
183
183
|
return false;
|
|
184
184
|
}
|
|
@@ -271,6 +271,12 @@ var testAttributes = [
|
|
|
271
271
|
dataType: import_types2.BizAttributeTypes.List,
|
|
272
272
|
bizType: import_types2.AttributeBizTypes.User
|
|
273
273
|
},
|
|
274
|
+
{
|
|
275
|
+
id: "tags-attr",
|
|
276
|
+
codeName: "tags",
|
|
277
|
+
dataType: import_types2.BizAttributeTypes.List,
|
|
278
|
+
bizType: import_types2.AttributeBizTypes.User
|
|
279
|
+
},
|
|
274
280
|
{
|
|
275
281
|
id: "signUpDate-attr",
|
|
276
282
|
codeName: "signUpDate",
|
|
@@ -315,6 +321,7 @@ var testUserAttributes = {
|
|
|
315
321
|
age: 25,
|
|
316
322
|
isPremium: true,
|
|
317
323
|
roles: ["admin", "user"],
|
|
324
|
+
tags: [123, 456],
|
|
318
325
|
signUpDate: "2024-01-15T10:30:00Z",
|
|
319
326
|
score: 85.5
|
|
320
327
|
};
|
|
@@ -678,35 +685,234 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
678
685
|
];
|
|
679
686
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
680
687
|
});
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
688
|
+
describe("notIncludesAtLeastOne condition", () => {
|
|
689
|
+
test("should return true when at least one value is not included (single value not included)", () => {
|
|
690
|
+
const condition = [
|
|
691
|
+
{
|
|
692
|
+
id: "condition-24",
|
|
693
|
+
type: "condition",
|
|
694
|
+
operators: "and",
|
|
695
|
+
data: {
|
|
696
|
+
logic: "notIncludesAtLeastOne",
|
|
697
|
+
listValues: ["guest"],
|
|
698
|
+
attrId: "roles-attr"
|
|
699
|
+
}
|
|
691
700
|
}
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
701
|
+
];
|
|
702
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
703
|
+
});
|
|
704
|
+
test("should return true when at least one value is not included (partial values not included)", () => {
|
|
705
|
+
const condition = [
|
|
706
|
+
{
|
|
707
|
+
id: "condition-24-2",
|
|
708
|
+
type: "condition",
|
|
709
|
+
operators: "and",
|
|
710
|
+
data: {
|
|
711
|
+
logic: "notIncludesAtLeastOne",
|
|
712
|
+
listValues: ["admin", "guest"],
|
|
713
|
+
attrId: "roles-attr"
|
|
714
|
+
}
|
|
706
715
|
}
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
716
|
+
];
|
|
717
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
718
|
+
});
|
|
719
|
+
test("should return true when all values are not included", () => {
|
|
720
|
+
const condition = [
|
|
721
|
+
{
|
|
722
|
+
id: "condition-24-3",
|
|
723
|
+
type: "condition",
|
|
724
|
+
operators: "and",
|
|
725
|
+
data: {
|
|
726
|
+
logic: "notIncludesAtLeastOne",
|
|
727
|
+
listValues: ["guest", "visitor"],
|
|
728
|
+
attrId: "roles-attr"
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
];
|
|
732
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
733
|
+
});
|
|
734
|
+
test("should return false when all values are included", () => {
|
|
735
|
+
const condition = [
|
|
736
|
+
{
|
|
737
|
+
id: "condition-24-4",
|
|
738
|
+
type: "condition",
|
|
739
|
+
operators: "and",
|
|
740
|
+
data: {
|
|
741
|
+
logic: "notIncludesAtLeastOne",
|
|
742
|
+
listValues: ["admin", "user"],
|
|
743
|
+
attrId: "roles-attr"
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
];
|
|
747
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
748
|
+
});
|
|
749
|
+
test("should return false when single value is included", () => {
|
|
750
|
+
const condition = [
|
|
751
|
+
{
|
|
752
|
+
id: "condition-24-5",
|
|
753
|
+
type: "condition",
|
|
754
|
+
operators: "and",
|
|
755
|
+
data: {
|
|
756
|
+
logic: "notIncludesAtLeastOne",
|
|
757
|
+
listValues: ["admin"],
|
|
758
|
+
attrId: "roles-attr"
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
];
|
|
762
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
763
|
+
});
|
|
764
|
+
test("should return true for numeric list when at least one value is not included", () => {
|
|
765
|
+
const condition = [
|
|
766
|
+
{
|
|
767
|
+
id: "condition-24-6",
|
|
768
|
+
type: "condition",
|
|
769
|
+
operators: "and",
|
|
770
|
+
data: {
|
|
771
|
+
logic: "notIncludesAtLeastOne",
|
|
772
|
+
listValues: [123, 444],
|
|
773
|
+
attrId: "tags-attr"
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
];
|
|
777
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
778
|
+
});
|
|
779
|
+
test("should return false for numeric list when all values are included", () => {
|
|
780
|
+
const condition = [
|
|
781
|
+
{
|
|
782
|
+
id: "condition-24-7",
|
|
783
|
+
type: "condition",
|
|
784
|
+
operators: "and",
|
|
785
|
+
data: {
|
|
786
|
+
logic: "notIncludesAtLeastOne",
|
|
787
|
+
listValues: [123, 456],
|
|
788
|
+
attrId: "tags-attr"
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
];
|
|
792
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
793
|
+
});
|
|
794
|
+
});
|
|
795
|
+
describe("notIncludesAll condition", () => {
|
|
796
|
+
test("should return true when all values are not included", () => {
|
|
797
|
+
const condition = [
|
|
798
|
+
{
|
|
799
|
+
id: "condition-25",
|
|
800
|
+
type: "condition",
|
|
801
|
+
operators: "and",
|
|
802
|
+
data: {
|
|
803
|
+
logic: "notIncludesAll",
|
|
804
|
+
listValues: ["guest", "visitor"],
|
|
805
|
+
attrId: "roles-attr"
|
|
806
|
+
}
|
|
807
|
+
}
|
|
808
|
+
];
|
|
809
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
810
|
+
});
|
|
811
|
+
test("should return true when single value is not included", () => {
|
|
812
|
+
const condition = [
|
|
813
|
+
{
|
|
814
|
+
id: "condition-25-2",
|
|
815
|
+
type: "condition",
|
|
816
|
+
operators: "and",
|
|
817
|
+
data: {
|
|
818
|
+
logic: "notIncludesAll",
|
|
819
|
+
listValues: ["guest"],
|
|
820
|
+
attrId: "roles-attr"
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
];
|
|
824
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
825
|
+
});
|
|
826
|
+
test("should return false when at least one value is included", () => {
|
|
827
|
+
const condition = [
|
|
828
|
+
{
|
|
829
|
+
id: "condition-25-3",
|
|
830
|
+
type: "condition",
|
|
831
|
+
operators: "and",
|
|
832
|
+
data: {
|
|
833
|
+
logic: "notIncludesAll",
|
|
834
|
+
listValues: ["admin", "guest"],
|
|
835
|
+
attrId: "roles-attr"
|
|
836
|
+
}
|
|
837
|
+
}
|
|
838
|
+
];
|
|
839
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
840
|
+
});
|
|
841
|
+
test("should return false when all values are included", () => {
|
|
842
|
+
const condition = [
|
|
843
|
+
{
|
|
844
|
+
id: "condition-25-4",
|
|
845
|
+
type: "condition",
|
|
846
|
+
operators: "and",
|
|
847
|
+
data: {
|
|
848
|
+
logic: "notIncludesAll",
|
|
849
|
+
listValues: ["admin", "user"],
|
|
850
|
+
attrId: "roles-attr"
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
];
|
|
854
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
855
|
+
});
|
|
856
|
+
test("should return false when single value is included", () => {
|
|
857
|
+
const condition = [
|
|
858
|
+
{
|
|
859
|
+
id: "condition-25-5",
|
|
860
|
+
type: "condition",
|
|
861
|
+
operators: "and",
|
|
862
|
+
data: {
|
|
863
|
+
logic: "notIncludesAll",
|
|
864
|
+
listValues: ["admin"],
|
|
865
|
+
attrId: "roles-attr"
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
];
|
|
869
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
870
|
+
});
|
|
871
|
+
test("should return true for numeric list when all values are not included", () => {
|
|
872
|
+
const condition = [
|
|
873
|
+
{
|
|
874
|
+
id: "condition-25-6",
|
|
875
|
+
type: "condition",
|
|
876
|
+
operators: "and",
|
|
877
|
+
data: {
|
|
878
|
+
logic: "notIncludesAll",
|
|
879
|
+
listValues: [1234, 789],
|
|
880
|
+
attrId: "tags-attr"
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
];
|
|
884
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
885
|
+
});
|
|
886
|
+
test("should return false for numeric list when at least one value is included", () => {
|
|
887
|
+
const condition = [
|
|
888
|
+
{
|
|
889
|
+
id: "condition-25-7",
|
|
890
|
+
type: "condition",
|
|
891
|
+
operators: "and",
|
|
892
|
+
data: {
|
|
893
|
+
logic: "notIncludesAll",
|
|
894
|
+
listValues: [123, 444],
|
|
895
|
+
attrId: "tags-attr"
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
];
|
|
899
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
900
|
+
});
|
|
901
|
+
test("should return false for numeric list when all values are included", () => {
|
|
902
|
+
const condition = [
|
|
903
|
+
{
|
|
904
|
+
id: "condition-25-8",
|
|
905
|
+
type: "condition",
|
|
906
|
+
operators: "and",
|
|
907
|
+
data: {
|
|
908
|
+
logic: "notIncludesAll",
|
|
909
|
+
listValues: [123, 456],
|
|
910
|
+
attrId: "tags-attr"
|
|
911
|
+
}
|
|
912
|
+
}
|
|
913
|
+
];
|
|
914
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
915
|
+
});
|
|
710
916
|
});
|
|
711
917
|
test('should evaluate "empty" condition correctly', () => {
|
|
712
918
|
const condition = [
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
evaluateAttributeCondition,
|
|
3
3
|
evaluateFilterConditions
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-E2APTIR7.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",
|
|
@@ -78,6 +84,7 @@ var testUserAttributes = {
|
|
|
78
84
|
age: 25,
|
|
79
85
|
isPremium: true,
|
|
80
86
|
roles: ["admin", "user"],
|
|
87
|
+
tags: [123, 456],
|
|
81
88
|
signUpDate: "2024-01-15T10:30:00Z",
|
|
82
89
|
score: 85.5
|
|
83
90
|
};
|
|
@@ -441,35 +448,234 @@ describe("Attribute Filter - Complete Test Suite", () => {
|
|
|
441
448
|
];
|
|
442
449
|
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
443
450
|
});
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
451
|
+
describe("notIncludesAtLeastOne condition", () => {
|
|
452
|
+
test("should return true when at least one value is not included (single value not included)", () => {
|
|
453
|
+
const condition = [
|
|
454
|
+
{
|
|
455
|
+
id: "condition-24",
|
|
456
|
+
type: "condition",
|
|
457
|
+
operators: "and",
|
|
458
|
+
data: {
|
|
459
|
+
logic: "notIncludesAtLeastOne",
|
|
460
|
+
listValues: ["guest"],
|
|
461
|
+
attrId: "roles-attr"
|
|
462
|
+
}
|
|
454
463
|
}
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
464
|
+
];
|
|
465
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
466
|
+
});
|
|
467
|
+
test("should return true when at least one value is not included (partial values not included)", () => {
|
|
468
|
+
const condition = [
|
|
469
|
+
{
|
|
470
|
+
id: "condition-24-2",
|
|
471
|
+
type: "condition",
|
|
472
|
+
operators: "and",
|
|
473
|
+
data: {
|
|
474
|
+
logic: "notIncludesAtLeastOne",
|
|
475
|
+
listValues: ["admin", "guest"],
|
|
476
|
+
attrId: "roles-attr"
|
|
477
|
+
}
|
|
469
478
|
}
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
479
|
+
];
|
|
480
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
481
|
+
});
|
|
482
|
+
test("should return true when all values are not included", () => {
|
|
483
|
+
const condition = [
|
|
484
|
+
{
|
|
485
|
+
id: "condition-24-3",
|
|
486
|
+
type: "condition",
|
|
487
|
+
operators: "and",
|
|
488
|
+
data: {
|
|
489
|
+
logic: "notIncludesAtLeastOne",
|
|
490
|
+
listValues: ["guest", "visitor"],
|
|
491
|
+
attrId: "roles-attr"
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
];
|
|
495
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
496
|
+
});
|
|
497
|
+
test("should return false when all values are included", () => {
|
|
498
|
+
const condition = [
|
|
499
|
+
{
|
|
500
|
+
id: "condition-24-4",
|
|
501
|
+
type: "condition",
|
|
502
|
+
operators: "and",
|
|
503
|
+
data: {
|
|
504
|
+
logic: "notIncludesAtLeastOne",
|
|
505
|
+
listValues: ["admin", "user"],
|
|
506
|
+
attrId: "roles-attr"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
];
|
|
510
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
511
|
+
});
|
|
512
|
+
test("should return false when single value is included", () => {
|
|
513
|
+
const condition = [
|
|
514
|
+
{
|
|
515
|
+
id: "condition-24-5",
|
|
516
|
+
type: "condition",
|
|
517
|
+
operators: "and",
|
|
518
|
+
data: {
|
|
519
|
+
logic: "notIncludesAtLeastOne",
|
|
520
|
+
listValues: ["admin"],
|
|
521
|
+
attrId: "roles-attr"
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
];
|
|
525
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
526
|
+
});
|
|
527
|
+
test("should return true for numeric list when at least one value is not included", () => {
|
|
528
|
+
const condition = [
|
|
529
|
+
{
|
|
530
|
+
id: "condition-24-6",
|
|
531
|
+
type: "condition",
|
|
532
|
+
operators: "and",
|
|
533
|
+
data: {
|
|
534
|
+
logic: "notIncludesAtLeastOne",
|
|
535
|
+
listValues: [123, 444],
|
|
536
|
+
attrId: "tags-attr"
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
];
|
|
540
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
541
|
+
});
|
|
542
|
+
test("should return false for numeric list when all values are included", () => {
|
|
543
|
+
const condition = [
|
|
544
|
+
{
|
|
545
|
+
id: "condition-24-7",
|
|
546
|
+
type: "condition",
|
|
547
|
+
operators: "and",
|
|
548
|
+
data: {
|
|
549
|
+
logic: "notIncludesAtLeastOne",
|
|
550
|
+
listValues: [123, 456],
|
|
551
|
+
attrId: "tags-attr"
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
];
|
|
555
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
describe("notIncludesAll condition", () => {
|
|
559
|
+
test("should return true when all values are not included", () => {
|
|
560
|
+
const condition = [
|
|
561
|
+
{
|
|
562
|
+
id: "condition-25",
|
|
563
|
+
type: "condition",
|
|
564
|
+
operators: "and",
|
|
565
|
+
data: {
|
|
566
|
+
logic: "notIncludesAll",
|
|
567
|
+
listValues: ["guest", "visitor"],
|
|
568
|
+
attrId: "roles-attr"
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
];
|
|
572
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
573
|
+
});
|
|
574
|
+
test("should return true when single value is not included", () => {
|
|
575
|
+
const condition = [
|
|
576
|
+
{
|
|
577
|
+
id: "condition-25-2",
|
|
578
|
+
type: "condition",
|
|
579
|
+
operators: "and",
|
|
580
|
+
data: {
|
|
581
|
+
logic: "notIncludesAll",
|
|
582
|
+
listValues: ["guest"],
|
|
583
|
+
attrId: "roles-attr"
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
];
|
|
587
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
588
|
+
});
|
|
589
|
+
test("should return false when at least one value is included", () => {
|
|
590
|
+
const condition = [
|
|
591
|
+
{
|
|
592
|
+
id: "condition-25-3",
|
|
593
|
+
type: "condition",
|
|
594
|
+
operators: "and",
|
|
595
|
+
data: {
|
|
596
|
+
logic: "notIncludesAll",
|
|
597
|
+
listValues: ["admin", "guest"],
|
|
598
|
+
attrId: "roles-attr"
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
];
|
|
602
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
603
|
+
});
|
|
604
|
+
test("should return false when all values are included", () => {
|
|
605
|
+
const condition = [
|
|
606
|
+
{
|
|
607
|
+
id: "condition-25-4",
|
|
608
|
+
type: "condition",
|
|
609
|
+
operators: "and",
|
|
610
|
+
data: {
|
|
611
|
+
logic: "notIncludesAll",
|
|
612
|
+
listValues: ["admin", "user"],
|
|
613
|
+
attrId: "roles-attr"
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
];
|
|
617
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
618
|
+
});
|
|
619
|
+
test("should return false when single value is included", () => {
|
|
620
|
+
const condition = [
|
|
621
|
+
{
|
|
622
|
+
id: "condition-25-5",
|
|
623
|
+
type: "condition",
|
|
624
|
+
operators: "and",
|
|
625
|
+
data: {
|
|
626
|
+
logic: "notIncludesAll",
|
|
627
|
+
listValues: ["admin"],
|
|
628
|
+
attrId: "roles-attr"
|
|
629
|
+
}
|
|
630
|
+
}
|
|
631
|
+
];
|
|
632
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
633
|
+
});
|
|
634
|
+
test("should return true for numeric list when all values are not included", () => {
|
|
635
|
+
const condition = [
|
|
636
|
+
{
|
|
637
|
+
id: "condition-25-6",
|
|
638
|
+
type: "condition",
|
|
639
|
+
operators: "and",
|
|
640
|
+
data: {
|
|
641
|
+
logic: "notIncludesAll",
|
|
642
|
+
listValues: [1234, 789],
|
|
643
|
+
attrId: "tags-attr"
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
];
|
|
647
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(true);
|
|
648
|
+
});
|
|
649
|
+
test("should return false for numeric list when at least one value is included", () => {
|
|
650
|
+
const condition = [
|
|
651
|
+
{
|
|
652
|
+
id: "condition-25-7",
|
|
653
|
+
type: "condition",
|
|
654
|
+
operators: "and",
|
|
655
|
+
data: {
|
|
656
|
+
logic: "notIncludesAll",
|
|
657
|
+
listValues: [123, 444],
|
|
658
|
+
attrId: "tags-attr"
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
];
|
|
662
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
663
|
+
});
|
|
664
|
+
test("should return false for numeric list when all values are included", () => {
|
|
665
|
+
const condition = [
|
|
666
|
+
{
|
|
667
|
+
id: "condition-25-8",
|
|
668
|
+
type: "condition",
|
|
669
|
+
operators: "and",
|
|
670
|
+
data: {
|
|
671
|
+
logic: "notIncludesAll",
|
|
672
|
+
listValues: [123, 456],
|
|
673
|
+
attrId: "tags-attr"
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
];
|
|
677
|
+
expect(evaluateFilterConditions(condition, defaultOptions)).toBe(false);
|
|
678
|
+
});
|
|
473
679
|
});
|
|
474
680
|
test('should evaluate "empty" condition correctly', () => {
|
|
475
681
|
const condition = [
|
|
@@ -276,9 +276,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
276
276
|
case "includesAll":
|
|
277
277
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
278
278
|
case "notIncludesAtLeastOne":
|
|
279
|
-
return
|
|
279
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
280
280
|
case "notIncludesAll":
|
|
281
|
-
return
|
|
281
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
282
282
|
default:
|
|
283
283
|
return false;
|
|
284
284
|
}
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
evaluateRulesConditions,
|
|
3
3
|
filterConditionsByType,
|
|
4
4
|
isConditionsActived
|
|
5
|
-
} from "../chunk-
|
|
5
|
+
} from "../chunk-YZQBWYCU.js";
|
|
6
6
|
import "../chunk-YYIGUZNZ.js";
|
|
7
7
|
import "../chunk-PAESAL23.js";
|
|
8
|
-
import "../chunk-
|
|
8
|
+
import "../chunk-E2APTIR7.js";
|
|
9
9
|
import "../chunk-CEK3SCQO.js";
|
|
10
10
|
import "../chunk-3KG2HTZ3.js";
|
|
11
11
|
import "../chunk-XEO3YXBM.js";
|
|
@@ -174,9 +174,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
174
174
|
case "includesAll":
|
|
175
175
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
176
176
|
case "notIncludesAtLeastOne":
|
|
177
|
-
return
|
|
177
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
178
178
|
case "notIncludesAll":
|
|
179
|
-
return
|
|
179
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
180
180
|
default:
|
|
181
181
|
return false;
|
|
182
182
|
}
|
|
@@ -196,9 +196,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
196
196
|
case "includesAll":
|
|
197
197
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
198
198
|
case "notIncludesAtLeastOne":
|
|
199
|
-
return
|
|
199
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
200
200
|
case "notIncludesAll":
|
|
201
|
-
return
|
|
201
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
202
202
|
default:
|
|
203
203
|
return false;
|
|
204
204
|
}
|
|
@@ -291,9 +291,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
291
291
|
case "includesAll":
|
|
292
292
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
293
293
|
case "notIncludesAtLeastOne":
|
|
294
|
-
return
|
|
294
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
295
295
|
case "notIncludesAll":
|
|
296
|
-
return
|
|
296
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
297
297
|
default:
|
|
298
298
|
return false;
|
|
299
299
|
}
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
isConditionsActived,
|
|
9
9
|
isEqual,
|
|
10
10
|
regenerateConditionIds
|
|
11
|
-
} from "../chunk-
|
|
11
|
+
} from "../chunk-YZQBWYCU.js";
|
|
12
12
|
import "../chunk-YYIGUZNZ.js";
|
|
13
13
|
import "../chunk-PAESAL23.js";
|
|
14
|
-
import "../chunk-
|
|
14
|
+
import "../chunk-E2APTIR7.js";
|
|
15
15
|
import "../chunk-CEK3SCQO.js";
|
|
16
16
|
import "../chunk-3KG2HTZ3.js";
|
|
17
17
|
import "../chunk-XEO3YXBM.js";
|
|
@@ -297,9 +297,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
297
297
|
case "includesAll":
|
|
298
298
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
299
299
|
case "notIncludesAtLeastOne":
|
|
300
|
-
return
|
|
300
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
301
301
|
case "notIncludesAll":
|
|
302
|
-
return
|
|
302
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
303
303
|
default:
|
|
304
304
|
return false;
|
|
305
305
|
}
|
package/dist/conditions/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
isConditionsActived,
|
|
10
10
|
isEqual,
|
|
11
11
|
regenerateConditionIds
|
|
12
|
-
} from "../chunk-
|
|
12
|
+
} from "../chunk-YZQBWYCU.js";
|
|
13
13
|
import {
|
|
14
14
|
evaluateUrlCondition,
|
|
15
15
|
isMatchUrlPattern
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import "../chunk-PAESAL23.js";
|
|
18
18
|
import {
|
|
19
19
|
evaluateAttributeCondition
|
|
20
|
-
} from "../chunk-
|
|
20
|
+
} from "../chunk-E2APTIR7.js";
|
|
21
21
|
import {
|
|
22
22
|
evaluateTimeCondition
|
|
23
23
|
} from "../chunk-CEK3SCQO.js";
|
package/dist/index.cjs
CHANGED
|
@@ -1262,9 +1262,9 @@ function evaluateListCondition(logic, actualValue, expectedValues) {
|
|
|
1262
1262
|
case "includesAll":
|
|
1263
1263
|
return filteredValues.every((value) => arrayValue.includes(value));
|
|
1264
1264
|
case "notIncludesAtLeastOne":
|
|
1265
|
-
return
|
|
1265
|
+
return filteredValues.some((value) => !arrayValue.includes(value));
|
|
1266
1266
|
case "notIncludesAll":
|
|
1267
|
-
return
|
|
1267
|
+
return filteredValues.every((value) => !arrayValue.includes(value));
|
|
1268
1268
|
default:
|
|
1269
1269
|
return false;
|
|
1270
1270
|
}
|
package/dist/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
isConditionsActived,
|
|
21
21
|
isEqual,
|
|
22
22
|
regenerateConditionIds
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-YZQBWYCU.js";
|
|
24
24
|
import {
|
|
25
25
|
evaluateUrlCondition,
|
|
26
26
|
isMatchUrlPattern
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
import "./chunk-PAESAL23.js";
|
|
29
29
|
import {
|
|
30
30
|
evaluateAttributeCondition
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-E2APTIR7.js";
|
|
32
32
|
import {
|
|
33
33
|
evaluateTimeCondition
|
|
34
34
|
} from "./chunk-CEK3SCQO.js";
|