@@ -585,6 +585,79 @@ describe('evaluation', () => {
585585 return new TestingProvider ( CONFIG , DELAY ) ; // delay init by 100ms
586586 } ;
587587
588+ describe ( 'provider ready event updates' , ( ) => {
589+ it ( 'should update EvaluationDetails when provider becomes ready (including reason)' , async ( ) => {
590+ const PROVIDER_READY_DOMAIN = 'provider-ready-test' ;
591+ const TEST_FLAG_KEY = 'test-flag' ;
592+ const FLAG_VALUE = true ;
593+
594+ // Create a provider that will delay initialization
595+ const provider = new TestingProvider (
596+ {
597+ [ TEST_FLAG_KEY ] : {
598+ disabled : false ,
599+ variants : {
600+ on : FLAG_VALUE ,
601+ off : false ,
602+ } ,
603+ defaultVariant : 'on' ,
604+ } ,
605+ } ,
606+ DELAY ,
607+ ) ;
608+
609+ OpenFeature . setProvider ( PROVIDER_READY_DOMAIN , provider ) ;
610+
611+ let capturedDetails : EvaluationDetails < boolean > | undefined ;
612+ let renderCount = 0 ;
613+
614+ function TestComponent ( ) {
615+ renderCount ++ ;
616+ const details = useBooleanFlagDetails ( TEST_FLAG_KEY , FLAG_VALUE ) ;
617+ capturedDetails = details ;
618+
619+ return (
620+ < div >
621+ < div data-testid = "value" > { String ( details . value ) } </ div >
622+ < div data-testid = "reason" > { details . reason } </ div >
623+ < div data-testid = "render-count" > { renderCount } </ div >
624+ </ div >
625+ ) ;
626+ }
627+
628+ render (
629+ < OpenFeatureProvider domain = { PROVIDER_READY_DOMAIN } >
630+ < TestComponent />
631+ </ OpenFeatureProvider > ,
632+ ) ;
633+
634+ // Initial render - provider is NOT_READY, should use default value with ERROR reason
635+ expect ( capturedDetails ?. value ) . toBe ( FLAG_VALUE ) ;
636+ expect ( capturedDetails ?. reason ) . toBe ( StandardResolutionReasons . ERROR ) ;
637+ expect ( capturedDetails ?. errorCode ) . toBe ( ErrorCode . PROVIDER_NOT_READY ) ;
638+ expect ( screen . getByTestId ( 'reason' ) ) . toHaveTextContent ( StandardResolutionReasons . ERROR ) ;
639+
640+ const initialRenderCount = renderCount ;
641+
642+ // Wait for provider to become ready and component to re-render
643+ await waitFor (
644+ ( ) => {
645+ expect ( capturedDetails ?. reason ) . toBe ( StandardResolutionReasons . STATIC ) ;
646+ } ,
647+ { timeout : DELAY * 2 } ,
648+ ) ;
649+
650+ // After provider is ready, same value but different reason and no error
651+ expect ( capturedDetails ?. value ) . toBe ( FLAG_VALUE ) ;
652+ expect ( capturedDetails ?. errorCode ) . toBeUndefined ( ) ;
653+ expect ( screen . getByTestId ( 'value' ) ) . toHaveTextContent ( String ( FLAG_VALUE ) ) ;
654+ expect ( screen . getByTestId ( 'reason' ) ) . toHaveTextContent ( StandardResolutionReasons . STATIC ) ;
655+
656+ // Verify that a re-render occurred
657+ expect ( renderCount ) . toBeGreaterThan ( initialRenderCount ) ;
658+ } ) ;
659+ } ) ;
660+
588661 describe ( 'when using the noop provider' , ( ) => {
589662 function TestComponent ( ) {
590663 const { value } = useSuspenseFlag ( SUSPENSE_FLAG_KEY , DEFAULT ) ;
0 commit comments