Skip to content

Commit 97ab814

Browse files
authored
feat: Add tests for implicit identity key with % Split (#35)
1 parent 6ab57ec commit 97ab814

File tree

2 files changed

+96
-0
lines changed

2 files changed

+96
-0
lines changed
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// Given: An identity key resulting in %54.53 allocation
3+
// and a % split segment on `$.identity.key` with %55 threshold
4+
// When: Evaluating the feature for the given identity
5+
// Then: The context should be considered part of the segment
6+
//
7+
// NOTE: The expectation is that the engine constructs the identity key internally
8+
// using the environment key and identity identifier. In this case, we expect
9+
// the constructed key to be "test_env_foobar" which results in 54.53% allocation.
10+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
11+
"context": {
12+
"environment": {
13+
"key": "test_env",
14+
"name": "Test Environment"
15+
},
16+
"identity": {
17+
"identifier": "foobar",
18+
"key": "test_env_foobar"
19+
},
20+
"features": {},
21+
"segments": {
22+
"12345": {
23+
"key": "12345",
24+
"name": "percentage_split_segment",
25+
"rules": [
26+
{
27+
"type": "ALL",
28+
"conditions": [
29+
{
30+
"operator": "PERCENTAGE_SPLIT",
31+
"property": "$.identity.key",
32+
"value": "55"
33+
}
34+
]
35+
}
36+
]
37+
}
38+
},
39+
},
40+
"result": {
41+
"flags": {},
42+
"segments": [
43+
{
44+
"name": "percentage_split_segment"
45+
}
46+
]
47+
}
48+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
// Given: A multivariate feature with one variant and an identity identifier
3+
// expected to produce an identity key resulting in %54.53 allocation
4+
// and a % split segment on `$.identity.key` with %55 threshold
5+
// When: Evaluating the feature for the given identity
6+
// Then: The context should be considered part of the segment
7+
//
8+
// NOTE: The expectation is that the engine constructs the identity key internally
9+
// using the environment key and identity identifier. In this case, we expect
10+
// the constructed key to be "test_env_foobar" which results in 54.53% allocation.
11+
"$schema": "https://raw.githubusercontent.com/Flagsmith/engine-test-data/refs/tags/v2.0.0/schema.json",
12+
"context": {
13+
"environment": {
14+
"key": "test_env",
15+
"name": "Test Environment"
16+
},
17+
"identity": {
18+
"identifier": "foobar"
19+
},
20+
"features": {},
21+
"segments": {
22+
"12345": {
23+
"key": "12345",
24+
"name": "percentage_split_segment",
25+
"rules": [
26+
{
27+
"type": "ALL",
28+
"conditions": [
29+
{
30+
"operator": "PERCENTAGE_SPLIT",
31+
"property": "$.identity.key",
32+
"value": "55"
33+
}
34+
]
35+
}
36+
]
37+
}
38+
},
39+
},
40+
"result": {
41+
"flags": {},
42+
"segments": [
43+
{
44+
"name": "percentage_split_segment"
45+
}
46+
]
47+
}
48+
}

0 commit comments

Comments
 (0)