@@ -266,6 +266,50 @@ describe('useRealPolicyWorkbench', () => {
266266 expect ( saveGroupPolicy ) . toHaveBeenNthCalledWith ( 2 , 'legal' , 'signature_flow' , 'ordered_numeric' , false )
267267 } )
268268
269+ it ( 'keeps explicit instance rule visible after saving when effective source remains group' , async ( ) => {
270+ let currentPolicy : any = {
271+ effectiveValue : 'parallel' ,
272+ allowedValues : [ 'parallel' , 'ordered_numeric' ] ,
273+ sourceScope : 'group' ,
274+ }
275+
276+ getPolicy . mockImplementation ( ( key : string ) => {
277+ if ( key === 'signature_flow' ) {
278+ return currentPolicy
279+ }
280+
281+ return null
282+ } )
283+
284+ saveSystemPolicy . mockImplementation ( async ( _policyKey : string , value : unknown ) => {
285+ currentPolicy = {
286+ effectiveValue : currentPolicy . effectiveValue ,
287+ allowedValues : currentPolicy . allowedValues ,
288+ sourceScope : 'group' ,
289+ }
290+
291+ return {
292+ effectiveValue : value ,
293+ sourceScope : 'group' ,
294+ allowedValues : [ 'parallel' , 'ordered_numeric' ] ,
295+ }
296+ } )
297+
298+ const state = createRealPolicyWorkbenchState ( )
299+ state . openSetting ( 'signature_flow' )
300+
301+ expect ( state . inheritedSystemRule ) . toBeNull ( )
302+
303+ state . startEditor ( { scope : 'system' } )
304+ state . updateDraftValue ( 'ordered_numeric' as never )
305+ await state . saveDraft ( )
306+
307+ expect ( saveSystemPolicy ) . toHaveBeenCalledWith ( 'signature_flow' , 'ordered_numeric' , true )
308+ expect ( state . inheritedSystemRule ) . not . toBeNull ( )
309+ expect ( state . inheritedSystemRule ?. value ) . toBe ( 'ordered_numeric' )
310+ expect ( state . hasGlobalDefault ) . toBe ( true )
311+ } )
312+
269313 it ( 'supports multi-target user save for signature_flow' , async ( ) => {
270314 const state = createRealPolicyWorkbenchState ( )
271315 state . openSetting ( 'signature_flow' )
@@ -357,7 +401,7 @@ describe('useRealPolicyWorkbench', () => {
357401 await state . removeRule ( 'system-default' )
358402
359403 expect ( saveSystemPolicy ) . toHaveBeenCalledTimes ( 1 )
360- expect ( saveSystemPolicy ) . toHaveBeenCalledWith ( 'signature_flow' , null )
404+ expect ( saveSystemPolicy ) . toHaveBeenCalledWith ( 'signature_flow' , null , false )
361405 } )
362406
363407 it ( 'closes editor when the edited system rule is reset' , async ( ) => {
@@ -400,7 +444,7 @@ describe('useRealPolicyWorkbench', () => {
400444 } )
401445
402446 it ( 'does not render a system default rule when effective value is baseline none' , ( ) => {
403- getPolicy . mockReturnValue ( { effectiveValue : 'none' } )
447+ getPolicy . mockReturnValue ( { effectiveValue : 'none' , sourceScope : 'system' } )
404448
405449 const state = createRealPolicyWorkbenchState ( )
406450 state . openSetting ( 'signature_flow' )
@@ -423,6 +467,20 @@ describe('useRealPolicyWorkbench', () => {
423467 expect ( state . summary ?. currentBaseValue ) . toBe ( 'Let users choose' )
424468 } )
425469
470+ it ( 'does not treat group-sourced effective value as explicit instance rule' , ( ) => {
471+ getPolicy . mockReturnValue ( {
472+ effectiveValue : 'parallel' ,
473+ sourceScope : 'group' ,
474+ allowedValues : [ 'none' , 'parallel' , 'ordered_numeric' ] ,
475+ } )
476+
477+ const state = createRealPolicyWorkbenchState ( )
478+ state . openSetting ( 'signature_flow' )
479+
480+ expect ( state . inheritedSystemRule ) . toBeNull ( )
481+ expect ( state . hasGlobalDefault ) . toBe ( false )
482+ } )
483+
426484 it ( 'prefills system rule creation with the current baseline value' , ( ) => {
427485 getPolicy . mockReturnValue ( {
428486 effectiveValue : 'ordered_numeric' ,
@@ -470,7 +528,7 @@ describe('useRealPolicyWorkbench', () => {
470528 it ( 'builds sticky summary metadata with precedence mode and fallback' , ( ) => {
471529 getPolicy . mockReturnValue ( {
472530 effectiveValue : 'ordered_numeric' ,
473- sourceScope : 'group ' ,
531+ sourceScope : 'global ' ,
474532 allowedValues : [ 'parallel' , 'ordered_numeric' ] ,
475533 } )
476534
0 commit comments