@@ -117,6 +117,28 @@ describe("workflowEditorStore", () => {
117117 expect ( store ( ) . draft ?. bindings . working [ 0 ] . label ) . toBe ( "Review" ) ;
118118 expect ( store ( ) . dirty ) . toBe ( false ) ;
119119 } ) ;
120+
121+ it ( "toggles the auto flag and marks dirty" , ( ) => {
122+ store ( ) . beginEdit ( makeConfig ( { ci_failing : [ makeAction ( { id : "a" } ) ] } ) ) ;
123+ store ( ) . updateAction ( "ci_failing" , "a" , { auto : true } ) ;
124+ expect ( store ( ) . draft ?. bindings . ci_failing [ 0 ] . auto ) . toBe ( true ) ;
125+ expect ( store ( ) . dirty ) . toBe ( true ) ;
126+ store ( ) . updateAction ( "ci_failing" , "a" , { auto : false } ) ;
127+ expect ( store ( ) . draft ?. bindings . ci_failing [ 0 ] . auto ) . toBe ( false ) ;
128+ } ) ;
129+
130+ it ( "clears dirty when auto is toggled on then back off" , ( ) => {
131+ // The editor sends `checked || undefined`, so disabling clears the key
132+ // rather than writing `auto: false`. That restores the exact baseline
133+ // serialization (no `auto` key), so the dirty flag must return to false —
134+ // otherwise an enable→disable round-trip falsely prompts an unsaved-changes save.
135+ store ( ) . beginEdit ( makeConfig ( { ci_failing : [ makeAction ( { id : "a" } ) ] } ) ) ;
136+ store ( ) . updateAction ( "ci_failing" , "a" , { auto : true } ) ;
137+ expect ( store ( ) . dirty ) . toBe ( true ) ;
138+ store ( ) . updateAction ( "ci_failing" , "a" , { auto : undefined } ) ;
139+ expect ( store ( ) . draft ?. bindings . ci_failing [ 0 ] . auto ) . toBeUndefined ( ) ;
140+ expect ( store ( ) . dirty ) . toBe ( false ) ;
141+ } ) ;
120142 } ) ;
121143
122144 describe ( "removeAction" , ( ) => {
0 commit comments