@@ -109,8 +109,25 @@ test('retrigger removes the previous outcome before applying the new one', async
109109 assert . deepEqual ( calls . added , [ 'community-assessment-needs-clarification' ] ) ;
110110} ) ;
111111
112- test ( 'mechanical cleanup has no agent-output dependency' , ( ) => {
112+ async function runCleanup ( { currentSha, eventSha, action = 'synchronize' , labels = [ ] } ) {
113+ const { github, calls } = fakeGitHub ( { sha : currentSha , labels } ) ;
114+ const context = {
115+ payload : { action, pull_request : { number : 7 , head : { sha : eventSha } } } ,
116+ repo : { owner : 'github' , repo : 'spec-kit' } ,
117+ } ;
118+ const core = { info ( ) { } } ;
119+ const run = new Function ( 'context' , 'github' , 'core' , `return (async () => {\n${ cleanupScript } \n})();` ) ;
120+ await run ( context , github , core ) ;
121+ return calls ;
122+ }
123+
124+ test ( 'mechanical cleanup removes fixed labels and skips stale synchronize events' , async ( ) => {
113125 assert . match ( cleanupScript , / p u l l s \. g e t / ) ;
114126 assert . match ( cleanupScript , / r e m o v e L a b e l / ) ;
115127 assert . doesNotMatch ( cleanupScript , / G H _ A W _ A G E N T _ O U T P U T | a g e n t _ o u t p u t / ) ;
128+ const sha = '1' . repeat ( 40 ) ;
129+ const removed = await runCleanup ( { currentSha : sha , eventSha : sha , labels : [ 'community-assessment-fits' , 'community-assessment-invalid' ] } ) ;
130+ assert . deepEqual ( removed . removed , [ 'community-assessment-fits' , 'community-assessment-invalid' ] ) ;
131+ const stale = await runCleanup ( { currentSha : '2' . repeat ( 40 ) , eventSha : '3' . repeat ( 40 ) , labels : [ 'community-assessment-fits' ] } ) ;
132+ assert . deepEqual ( stale . removed , [ ] ) ;
116133} ) ;
0 commit comments