@@ -2,11 +2,17 @@ import { evaluateRulesBasedConfiguration, matchesRule, OperatorType } from '@dat
22import { configurationFromString , configurationToString } from '@datadog/openfeature-browser'
33import { assert , reportSuccess } from './smoke'
44
5- const rulesResponse =
5+ const protobufRulesResponse =
66 'EgRwcm9kGigKDGJyb3dzZXItZmxhZxIYEAQaAigBIhAKCmFsbG9jYXRpb24iAiADGigKDGludGVnZXItZmxhZxIYEAIaAhgqIhAKCmFsbG9jYXRpb24iAiADKgJvbg=='
7- const configuration = configurationFromString ( JSON . stringify ( { version : 1 , rules : { response : rulesResponse } } ) )
7+ const configuration = configurationFromString (
8+ JSON . stringify ( { version : 1 , rules : { response : protobufRulesResponse } } )
9+ )
810
9- assert ( configuration . rules , 'rules configuration was not parsed' )
11+ assert ( configuration . rules , 'protobuf rules configuration was not decoded' )
12+ assert (
13+ configuration . rules . response . $typeName === 'datadog.ffe.flagging.ufc.v1.FlagsConfiguration' ,
14+ 'rules response is not a generated protobuf message'
15+ )
1016
1117const context = { targetingKey : 'browser-user' }
1218const booleanDetails = evaluateRulesBasedConfiguration (
@@ -42,13 +48,17 @@ const sha256Matched = matchesRule(
4248 { name : 'hello' }
4349)
4450
45- assert ( booleanDetails . value === true , 'boolean rule evaluation returned the wrong value' )
46- assert ( integerDetails . value === 42 , 'integer rule evaluation returned the wrong value' )
47- assert ( restored . rules ?. response . flags [ 'browser-flag' ] , 'rules configuration did not survive a round trip' )
51+ assert ( booleanDetails . value === true , 'protobuf boolean evaluation returned the wrong value' )
52+ assert ( integerDetails . value === 42 , 'protobuf int64 evaluation returned the wrong value' )
53+ assert (
54+ restored . rules ?. response . $typeName === 'datadog.ffe.flagging.ufc.v1.FlagsConfiguration' ,
55+ 'protobuf rules configuration did not survive a round trip'
56+ )
4857assert ( sha256Matched , 'SHA-256 condition did not match' )
4958
5059reportSuccess ( {
51- entrypoint : 'full' ,
60+ entrypoint : 'protobuf' ,
61+ protobufTypeName : configuration . rules . response . $typeName ,
5262 booleanValue : booleanDetails . value ,
5363 integerValue : integerDetails . value ,
5464 sha256Matched,
0 commit comments