growthbook 0.2.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/spec/cases.json DELETED
@@ -1,2873 +0,0 @@
1
- {
2
- "evalCondition": [
3
- [
4
- "$not - pass",
5
- {
6
- "$not": {
7
- "name": "hello"
8
- }
9
- },
10
- {
11
- "name": "world"
12
- },
13
- true
14
- ],
15
- [
16
- "$not - fail",
17
- {
18
- "$not": {
19
- "name": "hello"
20
- }
21
- },
22
- {
23
- "name": "hello"
24
- },
25
- false
26
- ],
27
- [
28
- "$and/$or - all true",
29
- {
30
- "$and": [
31
- {
32
- "father.age": {
33
- "$gt": 65
34
- }
35
- },
36
- {
37
- "$or": [
38
- {
39
- "bday": {
40
- "$regex": "-12-25$"
41
- }
42
- },
43
- {
44
- "name": "santa"
45
- }
46
- ]
47
- }
48
- ]
49
- },
50
- {
51
- "name": "santa",
52
- "bday": "1980-12-25",
53
- "father": {
54
- "age": 70
55
- }
56
- },
57
- true
58
- ],
59
- [
60
- "$and/$or - first or true",
61
- {
62
- "$and": [
63
- {
64
- "father.age": {
65
- "$gt": 65
66
- }
67
- },
68
- {
69
- "$or": [
70
- {
71
- "bday": {
72
- "$regex": "-12-25$"
73
- }
74
- },
75
- {
76
- "name": "santa"
77
- }
78
- ]
79
- }
80
- ]
81
- },
82
- {
83
- "name": "santa",
84
- "bday": "1980-12-20",
85
- "father": {
86
- "age": 70
87
- }
88
- },
89
- true
90
- ],
91
- [
92
- "$and/$or - second or true",
93
- {
94
- "$and": [
95
- {
96
- "father.age": {
97
- "$gt": 65
98
- }
99
- },
100
- {
101
- "$or": [
102
- {
103
- "bday": {
104
- "$regex": "-12-25$"
105
- }
106
- },
107
- {
108
- "name": "santa"
109
- }
110
- ]
111
- }
112
- ]
113
- },
114
- {
115
- "name": "barbara",
116
- "bday": "1980-12-25",
117
- "father": {
118
- "age": 70
119
- }
120
- },
121
- true
122
- ],
123
- [
124
- "$and/$or - first and false",
125
- {
126
- "$and": [
127
- {
128
- "father.age": {
129
- "$gt": 65
130
- }
131
- },
132
- {
133
- "$or": [
134
- {
135
- "bday": {
136
- "$regex": "-12-25$"
137
- }
138
- },
139
- {
140
- "name": "santa"
141
- }
142
- ]
143
- }
144
- ]
145
- },
146
- {
147
- "name": "santa",
148
- "bday": "1980-12-25",
149
- "father": {
150
- "age": 65
151
- }
152
- },
153
- false
154
- ],
155
- [
156
- "$and/$or - both or false",
157
- {
158
- "$and": [
159
- {
160
- "father.age": {
161
- "$gt": 65
162
- }
163
- },
164
- {
165
- "$or": [
166
- {
167
- "bday": {
168
- "$regex": "-12-25$"
169
- }
170
- },
171
- {
172
- "name": "santa"
173
- }
174
- ]
175
- }
176
- ]
177
- },
178
- {
179
- "name": "barbara",
180
- "bday": "1980-11-25",
181
- "father": {
182
- "age": 70
183
- }
184
- },
185
- false
186
- ],
187
- [
188
- "$and/$or - both and false",
189
- {
190
- "$and": [
191
- {
192
- "father.age": {
193
- "$gt": 65
194
- }
195
- },
196
- {
197
- "$or": [
198
- {
199
- "bday": {
200
- "$regex": "-12-25$"
201
- }
202
- },
203
- {
204
- "name": "santa"
205
- }
206
- ]
207
- }
208
- ]
209
- },
210
- {
211
- "name": "john smith",
212
- "bday": "1956-12-20",
213
- "father": {
214
- "age": 40
215
- }
216
- },
217
- false
218
- ],
219
- [
220
- "$exists - false pass",
221
- {
222
- "pets.dog.name": {
223
- "$exists": false
224
- }
225
- },
226
- {
227
- "hello": "world"
228
- },
229
- true
230
- ],
231
- [
232
- "$exists - false fail",
233
- {
234
- "pets.dog.name": {
235
- "$exists": false
236
- }
237
- },
238
- {
239
- "pets": {
240
- "dog": {
241
- "name": "fido"
242
- }
243
- }
244
- },
245
- false
246
- ],
247
- [
248
- "$exists - true fail",
249
- {
250
- "pets.dog.name": {
251
- "$exists": true
252
- }
253
- },
254
- {
255
- "hello": "world"
256
- },
257
- false
258
- ],
259
- [
260
- "$exists - true pass",
261
- {
262
- "pets.dog.name": {
263
- "$exists": true
264
- }
265
- },
266
- {
267
- "pets": {
268
- "dog": {
269
- "name": "fido"
270
- }
271
- }
272
- },
273
- true
274
- ],
275
- [
276
- "equals - multiple datatypes",
277
- {
278
- "str": "str",
279
- "num": 10,
280
- "flag": false
281
- },
282
- {
283
- "str": "str",
284
- "num": 10,
285
- "flag": false
286
- },
287
- true
288
- ],
289
- [
290
- "$in - pass",
291
- {
292
- "num": {
293
- "$in": [1, 2, 3]
294
- }
295
- },
296
- {
297
- "num": 2
298
- },
299
- true
300
- ],
301
- [
302
- "$in - fail",
303
- {
304
- "num": {
305
- "$in": [1, 2, 3]
306
- }
307
- },
308
- {
309
- "num": 4
310
- },
311
- false
312
- ],
313
- [
314
- "$nin - pass",
315
- {
316
- "num": {
317
- "$nin": [1, 2, 3]
318
- }
319
- },
320
- {
321
- "num": 4
322
- },
323
- true
324
- ],
325
- [
326
- "$nin - fail",
327
- {
328
- "num": {
329
- "$nin": [1, 2, 3]
330
- }
331
- },
332
- {
333
- "num": 2
334
- },
335
- false
336
- ],
337
- [
338
- "$elemMatch - pass - flat arrays",
339
- {
340
- "nums": {
341
- "$elemMatch": {
342
- "$gt": 10
343
- }
344
- }
345
- },
346
- {
347
- "nums": [0, 5, -20, 15]
348
- },
349
- true
350
- ],
351
- [
352
- "$elemMatch - fail - flat arrays",
353
- {
354
- "nums": {
355
- "$elemMatch": {
356
- "$gt": 10
357
- }
358
- }
359
- },
360
- {
361
- "nums": [0, 5, -20, 8]
362
- },
363
- false
364
- ],
365
- [
366
- "missing attribute - fail",
367
- {
368
- "pets.dog.name": {
369
- "$in": ["fido"]
370
- }
371
- },
372
- {
373
- "hello": "world"
374
- },
375
- false
376
- ],
377
- [
378
- "empty $or - pass",
379
- {
380
- "$or": []
381
- },
382
- {
383
- "hello": "world"
384
- },
385
- true
386
- ],
387
- [
388
- "empty $and - pass",
389
- {
390
- "$and": []
391
- },
392
- {
393
- "hello": "world"
394
- },
395
- true
396
- ],
397
- [
398
- "empty - pass",
399
- {},
400
- {
401
- "hello": "world"
402
- },
403
- true
404
- ],
405
- [
406
- "$eq - pass",
407
- {
408
- "occupation": {
409
- "$eq": "engineer"
410
- }
411
- },
412
- {
413
- "occupation": "engineer"
414
- },
415
- true
416
- ],
417
- [
418
- "$eq - fail",
419
- {
420
- "occupation": {
421
- "$eq": "engineer"
422
- }
423
- },
424
- {
425
- "occupation": "civil engineer"
426
- },
427
- false
428
- ],
429
- [
430
- "$ne - pass",
431
- {
432
- "level": {
433
- "$ne": "senior"
434
- }
435
- },
436
- {
437
- "level": "junior"
438
- },
439
- true
440
- ],
441
- [
442
- "$ne - fail",
443
- {
444
- "level": {
445
- "$ne": "senior"
446
- }
447
- },
448
- {
449
- "level": "senior"
450
- },
451
- false
452
- ],
453
- [
454
- "$regex - pass",
455
- {
456
- "userAgent": {
457
- "$regex": "(Mobile|Tablet)"
458
- }
459
- },
460
- {
461
- "userAgent": "Android Mobile Browser"
462
- },
463
- true
464
- ],
465
- [
466
- "$regex - fail",
467
- {
468
- "userAgent": {
469
- "$regex": "(Mobile|Tablet)"
470
- }
471
- },
472
- {
473
- "userAgent": "Chrome Desktop Browser"
474
- },
475
- false
476
- ],
477
- [
478
- "$gt/$lt numbers - pass",
479
- {
480
- "age": {
481
- "$gt": 30,
482
- "$lt": 60
483
- }
484
- },
485
- {
486
- "age": 50
487
- },
488
- true
489
- ],
490
- [
491
- "$gt/$lt numbers - fail $lt",
492
- {
493
- "age": {
494
- "$gt": 30,
495
- "$lt": 60
496
- }
497
- },
498
- {
499
- "age": 60
500
- },
501
- false
502
- ],
503
- [
504
- "$gt/$lt numbers - fail $gt",
505
- {
506
- "age": {
507
- "$gt": 30,
508
- "$lt": 60
509
- }
510
- },
511
- {
512
- "age": 30
513
- },
514
- false
515
- ],
516
- [
517
- "$gte/$lte numbers - pass",
518
- {
519
- "age": {
520
- "$gte": 30,
521
- "$lte": 60
522
- }
523
- },
524
- {
525
- "age": 50
526
- },
527
- true
528
- ],
529
- [
530
- "$gte/$lte numbers - pass $gte",
531
- {
532
- "age": {
533
- "$gte": 30,
534
- "$lte": 60
535
- }
536
- },
537
- {
538
- "age": 30
539
- },
540
- true
541
- ],
542
- [
543
- "$gte/$lte numbers - pass $lte",
544
- {
545
- "age": {
546
- "$gte": 30,
547
- "$lte": 60
548
- }
549
- },
550
- {
551
- "age": 60
552
- },
553
- true
554
- ],
555
- [
556
- "$gte/$lte numbers - fail $lte",
557
- {
558
- "age": {
559
- "$gte": 30,
560
- "$lte": 60
561
- }
562
- },
563
- {
564
- "age": 61
565
- },
566
- false
567
- ],
568
- [
569
- "$gte/$lte numbers - fail $gte",
570
- {
571
- "age": {
572
- "$gt": 30,
573
- "$lt": 60
574
- }
575
- },
576
- {
577
- "age": 29
578
- },
579
- false
580
- ],
581
- [
582
- "$gt/$lt strings - fail $gt",
583
- {
584
- "word": {
585
- "$gt": "alphabet",
586
- "$lt": "zebra"
587
- }
588
- },
589
- {
590
- "word": "alphabet"
591
- },
592
- false
593
- ],
594
- [
595
- "$gt/$lt strings - fail $lt",
596
- {
597
- "word": {
598
- "$gt": "alphabet",
599
- "$lt": "zebra"
600
- }
601
- },
602
- {
603
- "word": "zebra"
604
- },
605
- false
606
- ],
607
- [
608
- "$gt/$lt strings - pass",
609
- {
610
- "word": {
611
- "$gt": "alphabet",
612
- "$lt": "zebra"
613
- }
614
- },
615
- {
616
- "word": "always"
617
- },
618
- true
619
- ],
620
- [
621
- "$gt/$lt strings - fail uppercase",
622
- {
623
- "word": {
624
- "$gt": "alphabet",
625
- "$lt": "zebra"
626
- }
627
- },
628
- {
629
- "word": "AZL"
630
- },
631
- false
632
- ],
633
- [
634
- "nested value is null",
635
- {
636
- "address.state": "CA"
637
- },
638
- {
639
- "address": null
640
- },
641
- false
642
- ],
643
- [
644
- "nested value is integer",
645
- {
646
- "address.state": "CA"
647
- },
648
- {
649
- "address": 123
650
- },
651
- false
652
- ],
653
- [
654
- "$type string - pass",
655
- {
656
- "a": {
657
- "$type": "string"
658
- }
659
- },
660
- {
661
- "a": "a"
662
- },
663
- true
664
- ],
665
- [
666
- "$type string - fail",
667
- {
668
- "a": {
669
- "$type": "string"
670
- }
671
- },
672
- {
673
- "a": 1
674
- },
675
- false
676
- ],
677
- [
678
- "$type null - pass",
679
- {
680
- "a": {
681
- "$type": "null"
682
- }
683
- },
684
- {
685
- "a": null
686
- },
687
- true
688
- ],
689
- [
690
- "$type null - fail",
691
- {
692
- "a": {
693
- "$type": "null"
694
- }
695
- },
696
- {
697
- "a": 1
698
- },
699
- false
700
- ],
701
- [
702
- "$type boolean - pass",
703
- {
704
- "a": {
705
- "$type": "boolean"
706
- }
707
- },
708
- {
709
- "a": false
710
- },
711
- true
712
- ],
713
- [
714
- "$type boolean - fail",
715
- {
716
- "a": {
717
- "$type": "boolean"
718
- }
719
- },
720
- {
721
- "a": 1
722
- },
723
- false
724
- ],
725
- [
726
- "$type number - pass",
727
- {
728
- "a": {
729
- "$type": "number"
730
- }
731
- },
732
- {
733
- "a": 1
734
- },
735
- true
736
- ],
737
- [
738
- "$type number - fail",
739
- {
740
- "a": {
741
- "$type": "number"
742
- }
743
- },
744
- {
745
- "a": "a"
746
- },
747
- false
748
- ],
749
- [
750
- "$type object - pass",
751
- {
752
- "a": {
753
- "$type": "object"
754
- }
755
- },
756
- {
757
- "a": {
758
- "a": "b"
759
- }
760
- },
761
- true
762
- ],
763
- [
764
- "$type object - fail",
765
- {
766
- "a": {
767
- "$type": "object"
768
- }
769
- },
770
- {
771
- "a": 1
772
- },
773
- false
774
- ],
775
- [
776
- "$type array - pass",
777
- {
778
- "a": {
779
- "$type": "array"
780
- }
781
- },
782
- {
783
- "a": [1, 2]
784
- },
785
- true
786
- ],
787
- [
788
- "$type array - fail",
789
- {
790
- "a": {
791
- "$type": "array"
792
- }
793
- },
794
- {
795
- "a": 1
796
- },
797
- false
798
- ],
799
- [
800
- "unknown operator - pass",
801
- {
802
- "name": {
803
- "$regx": "hello"
804
- }
805
- },
806
- {
807
- "name": "hello"
808
- },
809
- false
810
- ],
811
- [
812
- "$regex invalid - pass",
813
- {
814
- "name": {
815
- "$regex": "/???***[)"
816
- }
817
- },
818
- {
819
- "name": "hello"
820
- },
821
- false
822
- ],
823
- [
824
- "$regex invalid - fail",
825
- {
826
- "name": {
827
- "$regex": "/???***[)"
828
- }
829
- },
830
- {
831
- "hello": "hello"
832
- },
833
- false
834
- ],
835
- [
836
- "$size empty - pass",
837
- {
838
- "tags": { "$size": 0 }
839
- },
840
- {
841
- "tags": []
842
- },
843
- true
844
- ],
845
- [
846
- "$size empty - fail",
847
- {
848
- "tags": { "$size": 0 }
849
- },
850
- {
851
- "tags": [10]
852
- },
853
- false
854
- ],
855
- [
856
- "$size number - pass",
857
- {
858
- "tags": {
859
- "$size": 3
860
- }
861
- },
862
- {
863
- "tags": ["a", "b", "c"]
864
- },
865
- true
866
- ],
867
- [
868
- "$size number - fail small",
869
- {
870
- "tags": {
871
- "$size": 3
872
- }
873
- },
874
- {
875
- "tags": ["a", "b"]
876
- },
877
- false
878
- ],
879
- [
880
- "$size number - fail large",
881
- {
882
- "tags": {
883
- "$size": 3
884
- }
885
- },
886
- {
887
- "tags": ["a", "b", "c", "d"]
888
- },
889
- false
890
- ],
891
- [
892
- "$size number - fail not array",
893
- {
894
- "tags": {
895
- "$size": 3
896
- }
897
- },
898
- {
899
- "tags": "abc"
900
- },
901
- false
902
- ],
903
- [
904
- "$size nested - pass",
905
- {
906
- "tags": {
907
- "$size": {
908
- "$gt": 2
909
- }
910
- }
911
- },
912
- {
913
- "tags": [0, 1, 2]
914
- },
915
- true
916
- ],
917
- [
918
- "$size nested - fail equal",
919
- {
920
- "tags": {
921
- "$size": {
922
- "$gt": 2
923
- }
924
- }
925
- },
926
- {
927
- "tags": [0, 1]
928
- },
929
- false
930
- ],
931
- [
932
- "$size nested - fail less than",
933
- {
934
- "tags": {
935
- "$size": {
936
- "$gt": 2
937
- }
938
- }
939
- },
940
- {
941
- "tags": [0]
942
- },
943
- false
944
- ],
945
- [
946
- "$elemMatch contains - pass",
947
- {
948
- "tags": {
949
- "$elemMatch": {
950
- "$eq": "bar"
951
- }
952
- }
953
- },
954
- {
955
- "tags": ["foo", "bar", "baz"]
956
- },
957
- true
958
- ],
959
- [
960
- "$elemMatch contains - false",
961
- {
962
- "tags": {
963
- "$elemMatch": {
964
- "$eq": "bar"
965
- }
966
- }
967
- },
968
- {
969
- "tags": ["foo", "baz"]
970
- },
971
- false
972
- ],
973
- [
974
- "$elemMatch not contains - pass",
975
- {
976
- "tags": {
977
- "$not": {
978
- "$elemMatch": {
979
- "$eq": "bar"
980
- }
981
- }
982
- }
983
- },
984
- {
985
- "tags": ["foo", "baz"]
986
- },
987
- true
988
- ],
989
- [
990
- "$elemMatch not contains - fail",
991
- {
992
- "tags": {
993
- "$not": {
994
- "$elemMatch": {
995
- "$eq": "bar"
996
- }
997
- }
998
- }
999
- },
1000
- {
1001
- "tags": ["foo", "bar", "baz"]
1002
- },
1003
- false
1004
- ],
1005
- [
1006
- "$elemMatch nested - pass",
1007
- {
1008
- "hobbies": {
1009
- "$elemMatch": {
1010
- "name": {
1011
- "$regex": "^ping"
1012
- }
1013
- }
1014
- }
1015
- },
1016
- {
1017
- "hobbies": [
1018
- {
1019
- "name": "bowling"
1020
- },
1021
- {
1022
- "name": "pingpong"
1023
- },
1024
- {
1025
- "name": "tennis"
1026
- }
1027
- ]
1028
- },
1029
- true
1030
- ],
1031
- [
1032
- "$elemMatch nested - fail",
1033
- {
1034
- "hobbies": {
1035
- "$elemMatch": {
1036
- "name": {
1037
- "$regex": "^ping"
1038
- }
1039
- }
1040
- }
1041
- },
1042
- {
1043
- "hobbies": [
1044
- {
1045
- "name": "bowling"
1046
- },
1047
- {
1048
- "name": "tennis"
1049
- }
1050
- ]
1051
- },
1052
- false
1053
- ],
1054
- [
1055
- "$elemMatch nested - fail not array",
1056
- {
1057
- "hobbies": {
1058
- "$elemMatch": {
1059
- "name": {
1060
- "$regex": "^ping"
1061
- }
1062
- }
1063
- }
1064
- },
1065
- {
1066
- "hobbies": "all"
1067
- },
1068
- false
1069
- ],
1070
- [
1071
- "$not - pass",
1072
- {
1073
- "name": {
1074
- "$not": {
1075
- "$regex": "^hello"
1076
- }
1077
- }
1078
- },
1079
- {
1080
- "name": "world"
1081
- },
1082
- true
1083
- ],
1084
- [
1085
- "$not - fail",
1086
- {
1087
- "name": {
1088
- "$not": {
1089
- "$regex": "^hello"
1090
- }
1091
- }
1092
- },
1093
- {
1094
- "name": "hello world"
1095
- },
1096
- false
1097
- ],
1098
- [
1099
- "$all - pass",
1100
- {
1101
- "tags": {
1102
- "$all": ["one", "three"]
1103
- }
1104
- },
1105
- {
1106
- "tags": ["one", "two", "three"]
1107
- },
1108
- true
1109
- ],
1110
- [
1111
- "$all - fail",
1112
- {
1113
- "tags": {
1114
- "$all": ["one", "three"]
1115
- }
1116
- },
1117
- {
1118
- "tags": ["one", "two", "four"]
1119
- },
1120
- false
1121
- ],
1122
- [
1123
- "$all - fail not array",
1124
- {
1125
- "tags": {
1126
- "$all": ["one", "three"]
1127
- }
1128
- },
1129
- {
1130
- "tags": "hello"
1131
- },
1132
- false
1133
- ],
1134
- [
1135
- "$nor - pass",
1136
- {
1137
- "$nor": [
1138
- {
1139
- "name": "john"
1140
- },
1141
- {
1142
- "age": {
1143
- "$lt": 30
1144
- }
1145
- }
1146
- ]
1147
- },
1148
- {
1149
- "name": "jim",
1150
- "age": 40
1151
- },
1152
- true
1153
- ],
1154
- [
1155
- "$nor - fail both",
1156
- {
1157
- "$nor": [
1158
- {
1159
- "name": "john"
1160
- },
1161
- {
1162
- "age": {
1163
- "$lt": 30
1164
- }
1165
- }
1166
- ]
1167
- },
1168
- {
1169
- "name": "john",
1170
- "age": 20
1171
- },
1172
- false
1173
- ],
1174
- [
1175
- "$nor - fail first",
1176
- {
1177
- "$nor": [
1178
- {
1179
- "name": "john"
1180
- },
1181
- {
1182
- "age": {
1183
- "$lt": 30
1184
- }
1185
- }
1186
- ]
1187
- },
1188
- {
1189
- "name": "john",
1190
- "age": 40
1191
- },
1192
- false
1193
- ],
1194
- [
1195
- "$nor - fail second",
1196
- {
1197
- "$nor": [
1198
- {
1199
- "name": "john"
1200
- },
1201
- {
1202
- "age": {
1203
- "$lt": 30
1204
- }
1205
- }
1206
- ]
1207
- },
1208
- {
1209
- "name": "jim",
1210
- "age": 20
1211
- },
1212
- false
1213
- ],
1214
- [
1215
- "equals array - pass",
1216
- {
1217
- "tags": ["hello", "world"]
1218
- },
1219
- {
1220
- "tags": ["hello", "world"]
1221
- },
1222
- true
1223
- ],
1224
- [
1225
- "equals array - fail order",
1226
- {
1227
- "tags": ["hello", "world"]
1228
- },
1229
- {
1230
- "tags": ["world", "hello"]
1231
- },
1232
- false
1233
- ],
1234
- [
1235
- "equals array - fail missing item",
1236
- {
1237
- "tags": ["hello", "world"]
1238
- },
1239
- {
1240
- "tags": ["hello"]
1241
- },
1242
- false
1243
- ],
1244
- [
1245
- "equals array - fail extra item",
1246
- {
1247
- "tags": ["hello", "world"]
1248
- },
1249
- {
1250
- "tags": ["hello", "world", "foo"]
1251
- },
1252
- false
1253
- ],
1254
- [
1255
- "equals array - fail type mismatch",
1256
- {
1257
- "tags": ["hello", "world"]
1258
- },
1259
- {
1260
- "tags": "hello world"
1261
- },
1262
- false
1263
- ],
1264
- [
1265
- "equals object - pass",
1266
- {
1267
- "tags": {
1268
- "hello": "world"
1269
- }
1270
- },
1271
- {
1272
- "tags": {
1273
- "hello": "world"
1274
- }
1275
- },
1276
- true
1277
- ],
1278
- [
1279
- "equals object - fail extra property",
1280
- {
1281
- "tags": {
1282
- "hello": "world"
1283
- }
1284
- },
1285
- {
1286
- "tags": {
1287
- "hello": "world",
1288
- "yes": "please"
1289
- }
1290
- },
1291
- false
1292
- ],
1293
- [
1294
- "equals object - fail missing property",
1295
- {
1296
- "tags": {
1297
- "hello": "world"
1298
- }
1299
- },
1300
- {
1301
- "tags": {}
1302
- },
1303
- false
1304
- ],
1305
- [
1306
- "equals object - fail type mismatch",
1307
- {
1308
- "tags": {
1309
- "hello": "world"
1310
- }
1311
- },
1312
- {
1313
- "tags": "hello world"
1314
- },
1315
- false
1316
- ]
1317
- ],
1318
- "hash": [
1319
- ["a", 0.22],
1320
- ["b", 0.077],
1321
- ["ab", 0.946],
1322
- ["def", 0.652],
1323
- ["8952klfjas09ujkasdf", 0.549],
1324
- ["123", 0.011],
1325
- ["___)((*\":&", 0.563]
1326
- ],
1327
- "getBucketRange": [
1328
- [
1329
- "normal 50/50",
1330
- [2, 1, null],
1331
- [
1332
- [0, 0.5],
1333
- [0.5, 1]
1334
- ]
1335
- ],
1336
- [
1337
- "reduced coverage",
1338
- [2, 0.5, null],
1339
- [
1340
- [0, 0.25],
1341
- [0.5, 0.75]
1342
- ]
1343
- ],
1344
- [
1345
- "zero coverage",
1346
- [2, 0, null],
1347
- [
1348
- [0, 0],
1349
- [0.5, 0.5]
1350
- ]
1351
- ],
1352
- [
1353
- "4 variations",
1354
- [4, 1, null],
1355
- [
1356
- [0, 0.25],
1357
- [0.25, 0.5],
1358
- [0.5, 0.75],
1359
- [0.75, 1]
1360
- ]
1361
- ],
1362
- [
1363
- "uneven weights",
1364
- [2, 1, [0.4, 0.6]],
1365
- [
1366
- [0, 0.4],
1367
- [0.4, 1]
1368
- ]
1369
- ],
1370
- [
1371
- "uneven weights, 3 variations",
1372
- [3, 1, [0.2, 0.3, 0.5]],
1373
- [
1374
- [0, 0.2],
1375
- [0.2, 0.5],
1376
- [0.5, 1]
1377
- ]
1378
- ],
1379
- [
1380
- "uneven weights, reduced coverage, 3 variations",
1381
- [3, 0.2, [0.2, 0.3, 0.5]],
1382
- [
1383
- [0, 0.04],
1384
- [0.2, 0.26],
1385
- [0.5, 0.6]
1386
- ]
1387
- ],
1388
- [
1389
- "negative coverage",
1390
- [2, -0.2, null],
1391
- [
1392
- [0, 0],
1393
- [0.5, 0.5]
1394
- ]
1395
- ],
1396
- [
1397
- "coverage above 1",
1398
- [2, 1.5, null],
1399
- [
1400
- [0, 0.5],
1401
- [0.5, 1]
1402
- ]
1403
- ],
1404
- [
1405
- "weights sum below 1",
1406
- [2, 1, [0.4, 0.1]],
1407
- [
1408
- [0, 0.5],
1409
- [0.5, 1]
1410
- ]
1411
- ],
1412
- [
1413
- "weights sum above 1",
1414
- [2, 1, [0.7, 0.6]],
1415
- [
1416
- [0, 0.5],
1417
- [0.5, 1]
1418
- ]
1419
- ],
1420
- [
1421
- "weights.length not equal to num variations",
1422
- [4, 1, [0.4, 0.4, 0.2]],
1423
- [
1424
- [0, 0.25],
1425
- [0.25, 0.5],
1426
- [0.5, 0.75],
1427
- [0.75, 1]
1428
- ]
1429
- ],
1430
- [
1431
- "weights sum almost equals 1",
1432
- [2, 1, [0.4, 0.5999]],
1433
- [
1434
- [0, 0.4],
1435
- [0.4, 0.9999]
1436
- ]
1437
- ]
1438
- ],
1439
- "feature": [
1440
- [
1441
- "unknown feature key",
1442
- {},
1443
- "my-feature",
1444
- {
1445
- "value": null,
1446
- "on": false,
1447
- "off": true,
1448
- "source": "unknownFeature"
1449
- }
1450
- ],
1451
- [
1452
- "defaults when empty",
1453
- { "features": { "feature": {} } },
1454
- "feature",
1455
- {
1456
- "value": null,
1457
- "on": false,
1458
- "off": true,
1459
- "source": "defaultValue"
1460
- }
1461
- ],
1462
- [
1463
- "uses defaultValue - number",
1464
- { "features": { "feature": { "defaultValue": 1 } } },
1465
- "feature",
1466
- {
1467
- "value": 1,
1468
- "on": true,
1469
- "off": false,
1470
- "source": "defaultValue"
1471
- }
1472
- ],
1473
- [
1474
- "uses custom values - string",
1475
- { "features": { "feature": { "defaultValue": "yes" } } },
1476
- "feature",
1477
- {
1478
- "value": "yes",
1479
- "on": true,
1480
- "off": false,
1481
- "source": "defaultValue"
1482
- }
1483
- ],
1484
- [
1485
- "force rules",
1486
- {
1487
- "features": {
1488
- "feature": {
1489
- "defaultValue": 2,
1490
- "rules": [
1491
- {
1492
- "force": 1
1493
- }
1494
- ]
1495
- }
1496
- }
1497
- },
1498
- "feature",
1499
- {
1500
- "value": 1,
1501
- "on": true,
1502
- "off": false,
1503
- "source": "force"
1504
- }
1505
- ],
1506
- [
1507
- "force rules - force false",
1508
- {
1509
- "features": {
1510
- "feature": {
1511
- "defaultValue": true,
1512
- "rules": [
1513
- {
1514
- "force": false
1515
- }
1516
- ]
1517
- }
1518
- }
1519
- },
1520
- "feature",
1521
- {
1522
- "value": false,
1523
- "on": false,
1524
- "off": true,
1525
- "source": "force"
1526
- }
1527
- ],
1528
- [
1529
- "force rules - coverage included",
1530
- {
1531
- "attributes": {
1532
- "id": "3"
1533
- },
1534
- "features": {
1535
- "feature": {
1536
- "defaultValue": 2,
1537
- "rules": [
1538
- {
1539
- "force": 1,
1540
- "coverage": 0.5
1541
- }
1542
- ]
1543
- }
1544
- }
1545
- },
1546
- "feature",
1547
- {
1548
- "value": 1,
1549
- "on": true,
1550
- "off": false,
1551
- "source": "force"
1552
- }
1553
- ],
1554
- [
1555
- "force rules - coverage excluded",
1556
- {
1557
- "attributes": {
1558
- "id": "1"
1559
- },
1560
- "features": {
1561
- "feature": {
1562
- "defaultValue": 2,
1563
- "rules": [
1564
- {
1565
- "force": 1,
1566
- "coverage": 0.5
1567
- }
1568
- ]
1569
- }
1570
- }
1571
- },
1572
- "feature",
1573
- {
1574
- "value": 2,
1575
- "on": true,
1576
- "off": false,
1577
- "source": "defaultValue"
1578
- }
1579
- ],
1580
- [
1581
- "force rules - coverage missing hashAttribute",
1582
- {
1583
- "attributes": {},
1584
- "features": {
1585
- "feature": {
1586
- "defaultValue": 2,
1587
- "rules": [
1588
- {
1589
- "force": 1,
1590
- "coverage": 0.5
1591
- }
1592
- ]
1593
- }
1594
- }
1595
- },
1596
- "feature",
1597
- {
1598
- "value": 2,
1599
- "on": true,
1600
- "off": false,
1601
- "source": "defaultValue"
1602
- }
1603
- ],
1604
- [
1605
- "force rules - condition pass",
1606
- {
1607
- "attributes": {
1608
- "country": "US",
1609
- "browser": "firefox"
1610
- },
1611
- "features": {
1612
- "feature": {
1613
- "defaultValue": 2,
1614
- "rules": [
1615
- {
1616
- "force": 1,
1617
- "condition": {
1618
- "country": { "$in": ["US", "CA"] },
1619
- "browser": "firefox"
1620
- }
1621
- }
1622
- ]
1623
- }
1624
- }
1625
- },
1626
- "feature",
1627
- {
1628
- "value": 1,
1629
- "on": true,
1630
- "off": false,
1631
- "source": "force"
1632
- }
1633
- ],
1634
- [
1635
- "force rules - condition fail",
1636
- {
1637
- "attributes": {
1638
- "country": "US",
1639
- "browser": "chrome"
1640
- },
1641
- "features": {
1642
- "feature": {
1643
- "defaultValue": 2,
1644
- "rules": [
1645
- {
1646
- "force": 1,
1647
- "condition": {
1648
- "country": { "$in": ["US", "CA"] },
1649
- "browser": "firefox"
1650
- }
1651
- }
1652
- ]
1653
- }
1654
- }
1655
- },
1656
- "feature",
1657
- {
1658
- "value": 2,
1659
- "on": true,
1660
- "off": false,
1661
- "source": "defaultValue"
1662
- }
1663
- ],
1664
- [
1665
- "ignores empty rules",
1666
- {
1667
- "features": {
1668
- "feature": {
1669
- "rules": [{}]
1670
- }
1671
- }
1672
- },
1673
- "feature",
1674
- {
1675
- "value": null,
1676
- "on": false,
1677
- "off": true,
1678
- "source": "defaultValue"
1679
- }
1680
- ],
1681
- [
1682
- "empty experiment rule - c",
1683
- {
1684
- "attributes": {
1685
- "id": "123"
1686
- },
1687
- "features": {
1688
- "feature": {
1689
- "rules": [
1690
- {
1691
- "variations": ["a", "b", "c"]
1692
- }
1693
- ]
1694
- }
1695
- }
1696
- },
1697
- "feature",
1698
- {
1699
- "value": "c",
1700
- "on": true,
1701
- "off": false,
1702
- "experiment": {
1703
- "key": "feature",
1704
- "variations": ["a", "b", "c"]
1705
- },
1706
- "experimentResult": {
1707
- "value": "c",
1708
- "variationId": 2,
1709
- "inExperiment": true,
1710
- "hashUsed": true,
1711
- "hashAttribute": "id",
1712
- "hashValue": "123"
1713
- },
1714
- "source": "experiment"
1715
- }
1716
- ],
1717
- [
1718
- "empty experiment rule - a",
1719
- {
1720
- "attributes": {
1721
- "id": "456"
1722
- },
1723
- "features": {
1724
- "feature": {
1725
- "rules": [
1726
- {
1727
- "variations": ["a", "b", "c"]
1728
- }
1729
- ]
1730
- }
1731
- }
1732
- },
1733
- "feature",
1734
- {
1735
- "value": "a",
1736
- "on": true,
1737
- "off": false,
1738
- "experiment": {
1739
- "key": "feature",
1740
- "variations": ["a", "b", "c"]
1741
- },
1742
- "experimentResult": {
1743
- "value": "a",
1744
- "variationId": 0,
1745
- "inExperiment": true,
1746
- "hashUsed": true,
1747
- "hashAttribute": "id",
1748
- "hashValue": "456"
1749
- },
1750
- "source": "experiment"
1751
- }
1752
- ],
1753
- [
1754
- "empty experiment rule - b",
1755
- {
1756
- "attributes": {
1757
- "id": "fds"
1758
- },
1759
- "features": {
1760
- "feature": {
1761
- "rules": [
1762
- {
1763
- "variations": ["a", "b", "c"]
1764
- }
1765
- ]
1766
- }
1767
- }
1768
- },
1769
- "feature",
1770
- {
1771
- "value": "b",
1772
- "on": true,
1773
- "off": false,
1774
- "experiment": {
1775
- "key": "feature",
1776
- "variations": ["a", "b", "c"]
1777
- },
1778
- "experimentResult": {
1779
- "value": "b",
1780
- "variationId": 1,
1781
- "inExperiment": true,
1782
- "hashUsed": true,
1783
- "hashAttribute": "id",
1784
- "hashValue": "fds"
1785
- },
1786
- "source": "experiment"
1787
- }
1788
- ],
1789
- [
1790
- "creates experiments properly",
1791
- {
1792
- "attributes": {
1793
- "anonId": "123",
1794
- "premium": true
1795
- },
1796
- "features": {
1797
- "feature": {
1798
- "rules": [
1799
- {
1800
- "coverage": 0.99,
1801
- "hashAttribute": "anonId",
1802
- "namespace": ["pricing", 0, 1],
1803
- "key": "hello",
1804
- "variations": [true, false],
1805
- "weights": [0.1, 0.9],
1806
- "condition": { "premium": true }
1807
- }
1808
- ]
1809
- }
1810
- }
1811
- },
1812
- "feature",
1813
- {
1814
- "value": false,
1815
- "on": false,
1816
- "off": true,
1817
- "source": "experiment",
1818
- "experiment": {
1819
- "coverage": 0.99,
1820
- "hashAttribute": "anonId",
1821
- "namespace": ["pricing", 0, 1],
1822
- "key": "hello",
1823
- "variations": [true, false],
1824
- "weights": [0.1, 0.9]
1825
- },
1826
- "experimentResult": {
1827
- "value": false,
1828
- "variationId": 1,
1829
- "inExperiment": true,
1830
- "hashUsed": true,
1831
- "hashAttribute": "anonId",
1832
- "hashValue": "123"
1833
- }
1834
- }
1835
- ],
1836
- [
1837
- "rule orders - skip 1",
1838
- {
1839
- "attributes": {
1840
- "browser": "firefox"
1841
- },
1842
- "features": {
1843
- "feature": {
1844
- "defaultValue": 0,
1845
- "rules": [
1846
- {
1847
- "force": 1,
1848
- "condition": { "browser": "chrome" }
1849
- },
1850
- {
1851
- "force": 2,
1852
- "condition": { "browser": "firefox" }
1853
- },
1854
- {
1855
- "force": 3,
1856
- "condition": { "browser": "safari" }
1857
- }
1858
- ]
1859
- }
1860
- }
1861
- },
1862
- "feature",
1863
- {
1864
- "value": 2,
1865
- "on": true,
1866
- "off": false,
1867
- "source": "force"
1868
- }
1869
- ],
1870
- [
1871
- "rule orders - skip 1,2",
1872
- {
1873
- "attributes": {
1874
- "browser": "safari"
1875
- },
1876
- "features": {
1877
- "feature": {
1878
- "defaultValue": 0,
1879
- "rules": [
1880
- {
1881
- "force": 1,
1882
- "condition": { "browser": "chrome" }
1883
- },
1884
- {
1885
- "force": 2,
1886
- "condition": { "browser": "firefox" }
1887
- },
1888
- {
1889
- "force": 3,
1890
- "condition": { "browser": "safari" }
1891
- }
1892
- ]
1893
- }
1894
- }
1895
- },
1896
- "feature",
1897
- {
1898
- "value": 3,
1899
- "on": true,
1900
- "off": false,
1901
- "source": "force"
1902
- }
1903
- ],
1904
- [
1905
- "rule orders - skip all",
1906
- {
1907
- "attributes": {
1908
- "browser": "ie"
1909
- },
1910
- "features": {
1911
- "feature": {
1912
- "defaultValue": 0,
1913
- "rules": [
1914
- {
1915
- "force": 1,
1916
- "condition": { "browser": "chrome" }
1917
- },
1918
- {
1919
- "force": 2,
1920
- "condition": { "browser": "firefox" }
1921
- },
1922
- {
1923
- "force": 3,
1924
- "condition": { "browser": "safari" }
1925
- }
1926
- ]
1927
- }
1928
- }
1929
- },
1930
- "feature",
1931
- {
1932
- "value": 0,
1933
- "on": false,
1934
- "off": true,
1935
- "source": "defaultValue"
1936
- }
1937
- ],
1938
- [
1939
- "skips experiment on coverage",
1940
- {
1941
- "attributes": { "id": "123" },
1942
- "features": {
1943
- "feature": {
1944
- "defaultValue": 0,
1945
- "rules": [
1946
- {
1947
- "variations": [0, 1, 2, 3],
1948
- "coverage": 0.01
1949
- },
1950
- {
1951
- "force": 3
1952
- }
1953
- ]
1954
- }
1955
- }
1956
- },
1957
- "feature",
1958
- {
1959
- "value": 3,
1960
- "on": true,
1961
- "off": false,
1962
- "source": "force"
1963
- }
1964
- ],
1965
- [
1966
- "skips experiment on namespace",
1967
- {
1968
- "attributes": { "id": "123" },
1969
- "features": {
1970
- "feature": {
1971
- "defaultValue": 0,
1972
- "rules": [
1973
- {
1974
- "variations": [0, 1, 2, 3],
1975
- "namespace": ["pricing", 0, 0.01]
1976
- },
1977
- {
1978
- "force": 3
1979
- }
1980
- ]
1981
- }
1982
- }
1983
- },
1984
- "feature",
1985
- {
1986
- "value": 3,
1987
- "on": true,
1988
- "off": false,
1989
- "source": "force"
1990
- }
1991
- ],
1992
- [
1993
- "skip experiment on missing hashAttribute",
1994
- {
1995
- "attributes": { "id": "123" },
1996
- "features": {
1997
- "feature": {
1998
- "defaultValue": 0,
1999
- "rules": [
2000
- {
2001
- "variations": [0, 1, 2, 3],
2002
- "hashAttribute": "company"
2003
- },
2004
- {
2005
- "force": 3
2006
- }
2007
- ]
2008
- }
2009
- }
2010
- },
2011
- "feature",
2012
- {
2013
- "value": 3,
2014
- "on": true,
2015
- "off": false,
2016
- "source": "force"
2017
- }
2018
- ],
2019
- [
2020
- "include experiments when forced",
2021
- {
2022
- "attributes": { "id": "123" },
2023
- "forcedVariations": {
2024
- "feature": 1
2025
- },
2026
- "features": {
2027
- "feature": {
2028
- "defaultValue": 0,
2029
- "rules": [
2030
- {
2031
- "variations": [0, 1, 2, 3]
2032
- },
2033
- {
2034
- "force": 3
2035
- }
2036
- ]
2037
- }
2038
- }
2039
- },
2040
- "feature",
2041
- {
2042
- "value": 1,
2043
- "on": true,
2044
- "off": false,
2045
- "source": "experiment",
2046
- "experiment": {
2047
- "key": "feature",
2048
- "variations": [0, 1, 2, 3]
2049
- },
2050
- "experimentResult": {
2051
- "value": 1,
2052
- "variationId": 1,
2053
- "inExperiment": true,
2054
- "hashUsed": false,
2055
- "hashAttribute": "id",
2056
- "hashValue": "123"
2057
- }
2058
- }
2059
- ]
2060
- ],
2061
- "run": [
2062
- [
2063
- "default weights - 1",
2064
- { "attributes": { "id": "1" } },
2065
- { "key": "my-test", "variations": [0, 1] },
2066
- 1,
2067
- true,
2068
- true
2069
- ],
2070
- [
2071
- "default weights - 2",
2072
- { "attributes": { "id": "2" } },
2073
- { "key": "my-test", "variations": [0, 1] },
2074
- 0,
2075
- true,
2076
- true
2077
- ],
2078
- [
2079
- "default weights - 3",
2080
- { "attributes": { "id": "3" } },
2081
- { "key": "my-test", "variations": [0, 1] },
2082
- 0,
2083
- true,
2084
- true
2085
- ],
2086
- [
2087
- "default weights - 4",
2088
- { "attributes": { "id": "4" } },
2089
- { "key": "my-test", "variations": [0, 1] },
2090
- 1,
2091
- true,
2092
- true
2093
- ],
2094
- [
2095
- "default weights - 5",
2096
- { "attributes": { "id": "5" } },
2097
- { "key": "my-test", "variations": [0, 1] },
2098
- 1,
2099
- true,
2100
- true
2101
- ],
2102
- [
2103
- "default weights - 6",
2104
- { "attributes": { "id": "6" } },
2105
- { "key": "my-test", "variations": [0, 1] },
2106
- 1,
2107
- true,
2108
- true
2109
- ],
2110
- [
2111
- "default weights - 7",
2112
- { "attributes": { "id": "7" } },
2113
- { "key": "my-test", "variations": [0, 1] },
2114
- 0,
2115
- true,
2116
- true
2117
- ],
2118
- [
2119
- "default weights - 8",
2120
- { "attributes": { "id": "8" } },
2121
- { "key": "my-test", "variations": [0, 1] },
2122
- 1,
2123
- true,
2124
- true
2125
- ],
2126
- [
2127
- "default weights - 9",
2128
- { "attributes": { "id": "9" } },
2129
- { "key": "my-test", "variations": [0, 1] },
2130
- 0,
2131
- true,
2132
- true
2133
- ],
2134
- [
2135
- "uneven weights - 1",
2136
- { "attributes": { "id": "1" } },
2137
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2138
- 1,
2139
- true,
2140
- true
2141
- ],
2142
- [
2143
- "uneven weights - 2",
2144
- { "attributes": { "id": "2" } },
2145
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2146
- 1,
2147
- true,
2148
- true
2149
- ],
2150
- [
2151
- "uneven weights - 3",
2152
- { "attributes": { "id": "3" } },
2153
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2154
- 0,
2155
- true,
2156
- true
2157
- ],
2158
- [
2159
- "uneven weights - 4",
2160
- { "attributes": { "id": "4" } },
2161
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2162
- 1,
2163
- true,
2164
- true
2165
- ],
2166
- [
2167
- "uneven weights - 5",
2168
- { "attributes": { "id": "5" } },
2169
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2170
- 1,
2171
- true,
2172
- true
2173
- ],
2174
- [
2175
- "uneven weights - 6",
2176
- { "attributes": { "id": "6" } },
2177
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2178
- 1,
2179
- true,
2180
- true
2181
- ],
2182
- [
2183
- "uneven weights - 7",
2184
- { "attributes": { "id": "7" } },
2185
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2186
- 0,
2187
- true,
2188
- true
2189
- ],
2190
- [
2191
- "uneven weights - 8",
2192
- { "attributes": { "id": "8" } },
2193
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2194
- 1,
2195
- true,
2196
- true
2197
- ],
2198
- [
2199
- "uneven weights - 9",
2200
- { "attributes": { "id": "9" } },
2201
- { "key": "my-test", "variations": [0, 1], "weights": [0.1, 0.9] },
2202
- 1,
2203
- true,
2204
- true
2205
- ],
2206
- [
2207
- "coverage - 1",
2208
- { "attributes": { "id": "1" } },
2209
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2210
- 0,
2211
- false,
2212
- false
2213
- ],
2214
- [
2215
- "coverage - 2",
2216
- { "attributes": { "id": "2" } },
2217
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2218
- 0,
2219
- true,
2220
- true
2221
- ],
2222
- [
2223
- "coverage - 3",
2224
- { "attributes": { "id": "3" } },
2225
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2226
- 0,
2227
- true,
2228
- true
2229
- ],
2230
- [
2231
- "coverage - 4",
2232
- { "attributes": { "id": "4" } },
2233
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2234
- 0,
2235
- false,
2236
- false
2237
- ],
2238
- [
2239
- "coverage - 5",
2240
- { "attributes": { "id": "5" } },
2241
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2242
- 1,
2243
- true,
2244
- true
2245
- ],
2246
- [
2247
- "coverage - 6",
2248
- { "attributes": { "id": "6" } },
2249
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2250
- 0,
2251
- false,
2252
- false
2253
- ],
2254
- [
2255
- "coverage - 7",
2256
- { "attributes": { "id": "7" } },
2257
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2258
- 0,
2259
- true,
2260
- true
2261
- ],
2262
- [
2263
- "coverage - 8",
2264
- { "attributes": { "id": "8" } },
2265
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2266
- 1,
2267
- true,
2268
- true
2269
- ],
2270
- [
2271
- "coverage - 9",
2272
- { "attributes": { "id": "9" } },
2273
- { "key": "my-test", "variations": [0, 1], "coverage": 0.4 },
2274
- 0,
2275
- false,
2276
- false
2277
- ],
2278
- [
2279
- "three way test - 1",
2280
- { "attributes": { "id": "1" } },
2281
- { "key": "my-test", "variations": [0, 1, 2] },
2282
- 2,
2283
- true,
2284
- true
2285
- ],
2286
- [
2287
- "three way test - 2",
2288
- { "attributes": { "id": "2" } },
2289
- { "key": "my-test", "variations": [0, 1, 2] },
2290
- 0,
2291
- true,
2292
- true
2293
- ],
2294
- [
2295
- "three way test - 3",
2296
- { "attributes": { "id": "3" } },
2297
- { "key": "my-test", "variations": [0, 1, 2] },
2298
- 0,
2299
- true,
2300
- true
2301
- ],
2302
- [
2303
- "three way test - 4",
2304
- { "attributes": { "id": "4" } },
2305
- { "key": "my-test", "variations": [0, 1, 2] },
2306
- 2,
2307
- true,
2308
- true
2309
- ],
2310
- [
2311
- "three way test - 5",
2312
- { "attributes": { "id": "5" } },
2313
- { "key": "my-test", "variations": [0, 1, 2] },
2314
- 1,
2315
- true,
2316
- true
2317
- ],
2318
- [
2319
- "three way test - 6",
2320
- { "attributes": { "id": "6" } },
2321
- { "key": "my-test", "variations": [0, 1, 2] },
2322
- 2,
2323
- true,
2324
- true
2325
- ],
2326
- [
2327
- "three way test - 7",
2328
- { "attributes": { "id": "7" } },
2329
- { "key": "my-test", "variations": [0, 1, 2] },
2330
- 0,
2331
- true,
2332
- true
2333
- ],
2334
- [
2335
- "three way test - 8",
2336
- { "attributes": { "id": "8" } },
2337
- { "key": "my-test", "variations": [0, 1, 2] },
2338
- 1,
2339
- true,
2340
- true
2341
- ],
2342
- [
2343
- "three way test - 9",
2344
- { "attributes": { "id": "9" } },
2345
- { "key": "my-test", "variations": [0, 1, 2] },
2346
- 0,
2347
- true,
2348
- true
2349
- ],
2350
- [
2351
- "test name - my-test",
2352
- { "attributes": { "id": "1" } },
2353
- { "key": "my-test", "variations": [0, 1] },
2354
- 1,
2355
- true,
2356
- true
2357
- ],
2358
- [
2359
- "test name - my-test-3",
2360
- { "attributes": { "id": "1" } },
2361
- { "key": "my-test-3", "variations": [0, 1] },
2362
- 0,
2363
- true,
2364
- true
2365
- ],
2366
- [
2367
- "empty id",
2368
- { "attributes": { "id": "" } },
2369
- { "key": "my-test", "variations": [0, 1] },
2370
- 0,
2371
- false,
2372
- false
2373
- ],
2374
- [
2375
- "missing id",
2376
- { "attributes": {} },
2377
- { "key": "my-test", "variations": [0, 1] },
2378
- 0,
2379
- false,
2380
- false
2381
- ],
2382
- [
2383
- "missing attributes",
2384
- {},
2385
- { "key": "my-test", "variations": [0, 1] },
2386
- 0,
2387
- false,
2388
- false
2389
- ],
2390
- [
2391
- "single variation",
2392
- { "attributes": { "id": "1" } },
2393
- { "key": "my-test", "variations": [0] },
2394
- 0,
2395
- false,
2396
- false
2397
- ],
2398
- [
2399
- "negative forced variation",
2400
- { "attributes": { "id": "1" } },
2401
- { "key": "my-test", "variations": [0, 1], "force": -8 },
2402
- 0,
2403
- false,
2404
- false
2405
- ],
2406
- [
2407
- "high forced variation",
2408
- { "attributes": { "id": "1" } },
2409
- { "key": "my-test", "variations": [0, 1], "force": 25 },
2410
- 0,
2411
- false,
2412
- false
2413
- ],
2414
- [
2415
- "evaluates conditions - pass",
2416
- {
2417
- "attributes": {
2418
- "id": "1",
2419
- "browser": "firefox"
2420
- }
2421
- },
2422
- {
2423
- "key": "my-test",
2424
- "variations": [0, 1],
2425
- "condition": {
2426
- "browser": "firefox"
2427
- }
2428
- },
2429
- 1,
2430
- true,
2431
- true
2432
- ],
2433
- [
2434
- "evaluates conditions - fail",
2435
- {
2436
- "attributes": {
2437
- "id": "1",
2438
- "browser": "chrome"
2439
- }
2440
- },
2441
- {
2442
- "key": "my-test",
2443
- "variations": [0, 1],
2444
- "condition": {
2445
- "browser": "firefox"
2446
- }
2447
- },
2448
- 0,
2449
- false,
2450
- false
2451
- ],
2452
- [
2453
- "custom hashAttribute",
2454
- {
2455
- "attributes": {
2456
- "id": "2",
2457
- "companyId": "1"
2458
- }
2459
- },
2460
- {
2461
- "key": "my-test",
2462
- "variations": [0, 1],
2463
- "hashAttribute": "companyId"
2464
- },
2465
- 1,
2466
- true,
2467
- true
2468
- ],
2469
- [
2470
- "globally disabled",
2471
- {
2472
- "attributes": {
2473
- "id": "1"
2474
- },
2475
- "enabled": false
2476
- },
2477
- {
2478
- "key": "my-test",
2479
- "variations": [0, 1]
2480
- },
2481
- 0,
2482
- false,
2483
- false
2484
- ],
2485
- [
2486
- "querystring force",
2487
- {
2488
- "attributes": {
2489
- "id": "1"
2490
- },
2491
- "url": "http://example.com?forced-test-qs=1#someanchor"
2492
- },
2493
- {
2494
- "key": "forced-test-qs",
2495
- "variations": [0, 1]
2496
- },
2497
- 1,
2498
- true,
2499
- false
2500
- ],
2501
- [
2502
- "run active experiments",
2503
- {
2504
- "attributes": {
2505
- "id": "1"
2506
- }
2507
- },
2508
- {
2509
- "key": "my-test",
2510
- "active": true,
2511
- "variations": [0, 1]
2512
- },
2513
- 1,
2514
- true,
2515
- true
2516
- ],
2517
- [
2518
- "skip inactive experiments",
2519
- {
2520
- "attributes": {
2521
- "id": "1"
2522
- }
2523
- },
2524
- {
2525
- "key": "my-test",
2526
- "active": false,
2527
- "variations": [0, 1]
2528
- },
2529
- 0,
2530
- false,
2531
- false
2532
- ],
2533
- [
2534
- "querystring force with inactive",
2535
- {
2536
- "attributes": {
2537
- "id": "1"
2538
- },
2539
- "url": "http://example.com/?my-test=1"
2540
- },
2541
- {
2542
- "key": "my-test",
2543
- "active": false,
2544
- "variations": [0, 1]
2545
- },
2546
- 1,
2547
- true,
2548
- false
2549
- ],
2550
- [
2551
- "coverage take precendence over forced",
2552
- {
2553
- "attributes": {
2554
- "id": "1"
2555
- }
2556
- },
2557
- {
2558
- "key": "my-test",
2559
- "force": 1,
2560
- "coverage": 0.01,
2561
- "variations": [0, 1]
2562
- },
2563
- 0,
2564
- false,
2565
- false
2566
- ],
2567
- [
2568
- "JSON values for experiments",
2569
- {
2570
- "attributes": {
2571
- "id": "1"
2572
- }
2573
- },
2574
- {
2575
- "key": "my-test",
2576
- "variations": [
2577
- {
2578
- "color": "blue",
2579
- "size": "small"
2580
- },
2581
- {
2582
- "color": "green",
2583
- "size": "large"
2584
- }
2585
- ]
2586
- },
2587
- {
2588
- "color": "green",
2589
- "size": "large"
2590
- },
2591
- true,
2592
- true
2593
- ],
2594
- [
2595
- "Force variation from context",
2596
- {
2597
- "attributes": { "id": "1" },
2598
- "forcedVariations": { "my-test": 0 }
2599
- },
2600
- {
2601
- "key": "my-test",
2602
- "variations": [0, 1]
2603
- },
2604
- 0,
2605
- true,
2606
- false
2607
- ],
2608
- [
2609
- "Skips experiments in QA mode",
2610
- {
2611
- "attributes": { "id": "1" },
2612
- "qaMode": true
2613
- },
2614
- {
2615
- "key": "my-test",
2616
- "variations": [0, 1]
2617
- },
2618
- 0,
2619
- false,
2620
- false
2621
- ],
2622
- [
2623
- "Works in QA mode if forced in context",
2624
- {
2625
- "attributes": { "id": "1" },
2626
- "qaMode": true,
2627
- "forcedVariations": { "my-test": 1 }
2628
- },
2629
- {
2630
- "key": "my-test",
2631
- "variations": [0, 1]
2632
- },
2633
- 1,
2634
- true,
2635
- false
2636
- ],
2637
- [
2638
- "Works in QA mode if forced in experiment",
2639
- {
2640
- "attributes": { "id": "1" },
2641
- "qaMode": true
2642
- },
2643
- {
2644
- "key": "my-test",
2645
- "variations": [0, 1],
2646
- "force": 1
2647
- },
2648
- 1,
2649
- true,
2650
- false
2651
- ],
2652
- [
2653
- "Experiment namespace - pass",
2654
- {
2655
- "attributes": {
2656
- "id": "1"
2657
- }
2658
- },
2659
- {
2660
- "key": "my-test",
2661
- "variations": [0, 1],
2662
- "namespace": ["namespace", 0.1, 1]
2663
- },
2664
- 1,
2665
- true,
2666
- true
2667
- ],
2668
- [
2669
- "Experiment namespace - fail",
2670
- {
2671
- "attributes": {
2672
- "id": "1"
2673
- }
2674
- },
2675
- {
2676
- "key": "my-test",
2677
- "variations": [0, 1],
2678
- "namespace": ["namespace", 0, 0.1]
2679
- },
2680
- 0,
2681
- false,
2682
- false
2683
- ]
2684
- ],
2685
- "chooseVariation": [
2686
- [
2687
- "even range, 0.2",
2688
- 0.2,
2689
- [
2690
- [0, 0.5],
2691
- [0.5, 1]
2692
- ],
2693
- 0
2694
- ],
2695
- [
2696
- "even range, 0.4",
2697
- 0.4,
2698
- [
2699
- [0, 0.5],
2700
- [0.5, 1]
2701
- ],
2702
- 0
2703
- ],
2704
- [
2705
- "even range, 0.6",
2706
- 0.6,
2707
- [
2708
- [0, 0.5],
2709
- [0.5, 1]
2710
- ],
2711
- 1
2712
- ],
2713
- [
2714
- "even range, 0.8",
2715
- 0.8,
2716
- [
2717
- [0, 0.5],
2718
- [0.5, 1]
2719
- ],
2720
- 1
2721
- ],
2722
- [
2723
- "even range, 0",
2724
- 0,
2725
- [
2726
- [0, 0.5],
2727
- [0.5, 1]
2728
- ],
2729
- 0
2730
- ],
2731
- [
2732
- "even range, 0.5",
2733
- 0.5,
2734
- [
2735
- [0, 0.5],
2736
- [0.5, 1]
2737
- ],
2738
- 1
2739
- ],
2740
- [
2741
- "reduced range, 0.2",
2742
- 0.2,
2743
- [
2744
- [0, 0.25],
2745
- [0.5, 0.75]
2746
- ],
2747
- 0
2748
- ],
2749
- [
2750
- "reduced range, 0.4",
2751
- 0.4,
2752
- [
2753
- [0, 0.25],
2754
- [0.5, 0.75]
2755
- ],
2756
- -1
2757
- ],
2758
- [
2759
- "reduced range, 0.6",
2760
- 0.6,
2761
- [
2762
- [0, 0.25],
2763
- [0.5, 0.75]
2764
- ],
2765
- 1
2766
- ],
2767
- [
2768
- "reduced range, 0.8",
2769
- 0.8,
2770
- [
2771
- [0, 0.25],
2772
- [0.5, 0.75]
2773
- ],
2774
- -1
2775
- ],
2776
- [
2777
- "reduced range, 0.25",
2778
- 0.25,
2779
- [
2780
- [0, 0.25],
2781
- [0.5, 0.75]
2782
- ],
2783
- -1
2784
- ],
2785
- [
2786
- "reduced range, 0.5",
2787
- 0.5,
2788
- [
2789
- [0, 0.25],
2790
- [0.5, 0.75]
2791
- ],
2792
- 1
2793
- ],
2794
- [
2795
- "zero range",
2796
- 0.5,
2797
- [
2798
- [0, 0.5],
2799
- [0.5, 0.5],
2800
- [0.5, 1]
2801
- ],
2802
- 2
2803
- ]
2804
- ],
2805
- "getQueryStringOverride": [
2806
- ["empty url", "my-test", "", 2, null],
2807
- ["no query string", "my-test", "http://example.com", 2, null],
2808
- ["empty query string", "my-test", "http://example.com?", 2, null],
2809
- [
2810
- "no query string match",
2811
- "my-test",
2812
- "http://example.com?somequery",
2813
- 2,
2814
- null
2815
- ],
2816
- ["invalid query string", "my-test", "http://example.com??&&&?#", 2, null],
2817
- ["simple match 0", "my-test", "http://example.com?my-test=0", 2, 0],
2818
- ["simple match 1", "my-test", "http://example.com?my-test=1", 2, 1],
2819
- ["negative variation", "my-test", "http://example.com?my-test=-1", 2, null],
2820
- ["float", "my-test", "http://example.com?my-test=2.054", 2, null],
2821
- ["string", "my-test", "http://example.com?my-test=foo", 2, null],
2822
- ["variation too high", "my-test", "http://example.com?my-test=5", 2, null],
2823
- ["high numVariations", "my-test", "http://example.com?my-test=5", 6, 5],
2824
- [
2825
- "equal to numVariations",
2826
- "my-test",
2827
- "http://example.com?my-test=5",
2828
- 5,
2829
- null
2830
- ],
2831
- [
2832
- "other query string before",
2833
- "my-test",
2834
- "http://example.com?foo=bar&my-test=1",
2835
- 2,
2836
- 1
2837
- ],
2838
- [
2839
- "other query string after",
2840
- "my-test",
2841
- "http://example.com?foo=bar&my-test=1&bar=baz",
2842
- 2,
2843
- 1
2844
- ],
2845
- ["anchor", "my-test", "http://example.com?my-test=1#foo", 2, 1]
2846
- ],
2847
- "inNamespace": [
2848
- ["user 1, namespace1, 1", "1", ["namespace1", 0, 0.4], false],
2849
- ["user 1, namespace1, 2", "1", ["namespace1", 0.4, 1], true],
2850
- ["user 1, namespace2, 1", "1", ["namespace2", 0, 0.4], false],
2851
- ["user 1, namespace2, 2", "1", ["namespace2", 0.4, 1], true],
2852
- ["user 2, namespace1, 1", "2", ["namespace1", 0, 0.4], false],
2853
- ["user 2, namespace1, 2", "2", ["namespace1", 0.4, 1], true],
2854
- ["user 2, namespace2, 1", "2", ["namespace2", 0, 0.4], false],
2855
- ["user 2, namespace2, 2", "2", ["namespace2", 0.4, 1], true],
2856
- ["user 3, namespace1, 1", "3", ["namespace1", 0, 0.4], false],
2857
- ["user 3, namespace1, 2", "3", ["namespace1", 0.4, 1], true],
2858
- ["user 3, namespace2, 1", "3", ["namespace2", 0, 0.4], true],
2859
- ["user 3, namespace2, 2", "3", ["namespace2", 0.4, 1], false],
2860
- ["user 4, namespace1, 1", "4", ["namespace1", 0, 0.4], false],
2861
- ["user 4, namespace1, 2", "4", ["namespace1", 0.4, 1], true],
2862
- ["user 4, namespace2, 1", "4", ["namespace2", 0, 0.4], true],
2863
- ["user 4, namespace2, 2", "4", ["namespace2", 0.4, 1], false]
2864
- ],
2865
- "getEqualWeights": [
2866
- [-1, []],
2867
- [0, []],
2868
- [1, [1]],
2869
- [2, [0.5, 0.5]],
2870
- [3, [0.33333333, 0.33333333, 0.33333333]],
2871
- [4, [0.25, 0.25, 0.25, 0.25]]
2872
- ]
2873
- }