@@ -547,6 +547,7 @@ describe('ProjectSeer', () => {
547547 it ( 'hides Scan Issues toggle when triage-signals-v0 feature flag is enabled' , async ( ) => {
548548 const projectWithFeatureFlag = ProjectFixture ( {
549549 features : [ 'triage-signals-v0' ] ,
550+ autofixAutomationTuning : 'medium' , // Already enabled, so no auto-enable PUT
550551 } ) ;
551552
552553 render ( < ProjectSeer /> , {
@@ -583,7 +584,7 @@ describe('ProjectSeer', () => {
583584 const projectWithFlag = ProjectFixture ( {
584585 features : [ 'triage-signals-v0' ] ,
585586 seerScannerAutomation : true ,
586- autofixAutomationTuning : 'off' ,
587+ autofixAutomationTuning : 'medium' , // Already enabled, so no auto-enable PUT
587588 } ) ;
588589
589590 const { unmount} = render ( < ProjectSeer /> , {
@@ -620,30 +621,16 @@ describe('ProjectSeer', () => {
620621 ) . not . toBeInTheDocument ( ) ;
621622 } ) ;
622623
623- it ( 'maps values correctly: off=unchecked, others=checked' , async ( ) => {
624- const { unmount} = render ( < ProjectSeer /> , {
625- organization,
626- outletContext : {
627- project : ProjectFixture ( {
628- features : [ 'triage-signals-v0' ] ,
629- seerScannerAutomation : true ,
630- autofixAutomationTuning : 'off' ,
631- } ) ,
632- } ,
633- } ) ;
634-
635- expect (
636- await screen . findByRole ( 'checkbox' , { name : / A u t o - T r i g g e r F i x e s / i} )
637- ) . not . toBeChecked ( ) ;
638- unmount ( ) ;
639-
624+ it ( 'toggle is always checked when triage-signals-v0 flag is enabled' , async ( ) => {
625+ // When flag is on, the toggle is always checked regardless of stored value
626+ // because we default to ON for triage signals users
640627 render ( < ProjectSeer /> , {
641628 organization,
642629 outletContext : {
643630 project : ProjectFixture ( {
644631 features : [ 'triage-signals-v0' ] ,
645632 seerScannerAutomation : true ,
646- autofixAutomationTuning : 'high ' ,
633+ autofixAutomationTuning : 'medium ' ,
647634 } ) ,
648635 } ,
649636 } ) ;
@@ -666,30 +653,70 @@ describe('ProjectSeer', () => {
666653 project : ProjectFixture ( {
667654 features : [ 'triage-signals-v0' ] ,
668655 seerScannerAutomation : true ,
669- autofixAutomationTuning : 'off' ,
656+ autofixAutomationTuning : 'medium' , // Start with enabled so no auto-enable
670657 } ) ,
671658 } ,
672659 } ) ;
673660
674661 const toggle = await screen . findByRole ( 'checkbox' , { name : / A u t o - T r i g g e r F i x e s / i} ) ;
662+ expect ( toggle ) . toBeChecked ( ) ;
663+
664+ // Toggle OFF
675665 await userEvent . click ( toggle ) ;
676666
677667 await waitFor ( ( ) => {
678668 expect ( projectPutRequest ) . toHaveBeenCalledWith (
679669 expect . any ( String ) ,
680- expect . objectContaining ( { data : { autofixAutomationTuning : 'medium ' } } )
670+ expect . objectContaining ( { data : { autofixAutomationTuning : 'off ' } } )
681671 ) ;
682672 } ) ;
683673
674+ // Toggle back ON
684675 await userEvent . click ( toggle ) ;
685676
686677 await waitFor ( ( ) => {
687678 expect ( projectPutRequest ) . toHaveBeenCalledWith (
688679 expect . any ( String ) ,
689- expect . objectContaining ( { data : { autofixAutomationTuning : 'off ' } } )
680+ expect . objectContaining ( { data : { autofixAutomationTuning : 'medium ' } } )
690681 ) ;
691682 } ) ;
692683 } ) ;
684+
685+ it ( 'respects existing off setting for orgs with flag enabled' , async ( ) => {
686+ render ( < ProjectSeer /> , {
687+ organization,
688+ outletContext : {
689+ project : ProjectFixture ( {
690+ features : [ 'triage-signals-v0' ] ,
691+ seerScannerAutomation : true ,
692+ autofixAutomationTuning : 'off' , // Existing org with it disabled
693+ } ) ,
694+ } ,
695+ } ) ;
696+
697+ // Toggle should be unchecked, respecting the existing 'off' setting
698+ expect (
699+ await screen . findByRole ( 'checkbox' , { name : / A u t o - T r i g g e r F i x e s / i} )
700+ ) . not . toBeChecked ( ) ;
701+ } ) ;
702+
703+ it ( 'defaults to ON for new orgs (undefined value)' , async ( ) => {
704+ render ( < ProjectSeer /> , {
705+ organization,
706+ outletContext : {
707+ project : ProjectFixture ( {
708+ features : [ 'triage-signals-v0' ] ,
709+ seerScannerAutomation : true ,
710+ autofixAutomationTuning : undefined , // New org
711+ } ) ,
712+ } ,
713+ } ) ;
714+
715+ // Toggle should be checked for new orgs
716+ expect (
717+ await screen . findByRole ( 'checkbox' , { name : / A u t o - T r i g g e r F i x e s / i} )
718+ ) . toBeChecked ( ) ;
719+ } ) ;
693720 } ) ;
694721
695722 describe ( 'Auto Create PR Setting' , ( ) => {
0 commit comments