Skip to content

Commit 6453b03

Browse files
khvn26Zaimwa9
andauthored
feat: Add FeatureValue.variants[].priority sorting tests (#28)
Co-authored-by: Zaimwa9 <[email protected]>
1 parent 3d26dc5 commit 6453b03

File tree

2 files changed

+102
-0
lines changed

2 files changed

+102
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
// Given: A multivariate feature with two variants of equal weight, where option_b has a stronger priority (lower priority number)
3+
// and an identity resulting in 49.27% percentage allocation
4+
// When: Evaluating the feature for the given identity
5+
// Then: The variant with stronger priority (option_a) should be selected as the feature value
6+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
7+
"context": {
8+
"environment": {
9+
"key": "test_env",
10+
"name": "Test Environment"
11+
},
12+
"identity": {
13+
"identifier": "0cfd0d72-4de4-4ed7-9cfb-d80dc3dacead",
14+
"key": "32103813"
15+
},
16+
"features": {
17+
"multivariate_feature": {
18+
"enabled": true,
19+
"feature_key": "15062",
20+
"key": "78986",
21+
"name": "multivariate_feature",
22+
"value": "foo",
23+
"variants": [
24+
{
25+
"value": "option_a",
26+
"weight": 50,
27+
"priority": 10
28+
},
29+
{
30+
"value": "option_b",
31+
"weight": 50,
32+
"priority": 20
33+
}
34+
]
35+
}
36+
},
37+
"segments": {}
38+
},
39+
"result": {
40+
"flags": {
41+
"multivariate_feature": {
42+
"enabled": true,
43+
"feature_key": "15062",
44+
"name": "multivariate_feature",
45+
"reason": "SPLIT; weight=50",
46+
"value": "option_a"
47+
}
48+
},
49+
"segments": []
50+
}
51+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
// Given: A multivariate feature with two variants of equal weight, where option_b has a stronger priority (lower priority number)
3+
// and an identity resulting in 49.27% percentage allocation
4+
// When: Evaluating the feature for the given identity
5+
// Then: The variant with stronger priority (option_b) should be selected as the feature value
6+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
7+
"context": {
8+
"environment": {
9+
"key": "test_env",
10+
"name": "Test Environment"
11+
},
12+
"identity": {
13+
"identifier": "0cfd0d72-4de4-4ed7-9cfb-d80dc3dacead",
14+
"key": "32103813"
15+
},
16+
"features": {
17+
"multivariate_feature": {
18+
"enabled": true,
19+
"feature_key": "15062",
20+
"key": "78986",
21+
"name": "multivariate_feature",
22+
"value": "foo",
23+
"variants": [
24+
{
25+
"value": "option_a",
26+
"weight": 50,
27+
"priority": 20
28+
},
29+
{
30+
"value": "option_b",
31+
"weight": 50,
32+
"priority": 10
33+
}
34+
]
35+
}
36+
},
37+
"segments": {}
38+
},
39+
"result": {
40+
"flags": {
41+
"multivariate_feature": {
42+
"enabled": true,
43+
"feature_key": "15062",
44+
"name": "multivariate_feature",
45+
"reason": "SPLIT; weight=50",
46+
"value": "option_b"
47+
}
48+
},
49+
"segments": []
50+
}
51+
}

0 commit comments

Comments
 (0)