@@ -30,6 +30,10 @@ vi.mock('@/executor/handlers/pi/core/keys', () => ({
3030 mapThinkingLevel : ( ) => 'high' ,
3131} ) )
3232
33+ import {
34+ PI_EVENT_FILTER_PATH ,
35+ PI_EVENT_FILTER_SOURCE ,
36+ } from '@/executor/handlers/pi/cloud/event-filter-source'
3337import { runCloudPlanPi } from '@/executor/handlers/pi/cloud/plan/backend'
3438import type { PiCloudPlanRunParams } from '@/executor/handlers/pi/core/backend'
3539import {
@@ -99,6 +103,7 @@ describe('runCloudPlanPi', () => {
99103
100104 const [ piCommand , piOptions ] = mockRun . mock . calls [ 1 ]
101105 expect ( piCommand ) . toContain ( '--no-extensions --no-prompt-templates --no-skills --no-approve' )
106+ expect ( piCommand ) . toContain ( `| node ${ PI_EVENT_FILTER_PATH } ` )
102107 expect ( piCommand ) . not . toContain ( 'git commit' )
103108 expect ( piCommand ) . not . toContain ( 'git push' )
104109 expect ( piOptions . envs . ANTHROPIC_API_KEY ) . toBe ( 'sk-model-secret' )
@@ -116,6 +121,18 @@ describe('runCloudPlanPi', () => {
116121 } )
117122 )
118123 expect ( mockWriteFile ) . toHaveBeenCalledWith ( '/workspace/pi-prompt.txt' , 'PLAN PROMPT' )
124+ expect ( mockWriteFile ) . toHaveBeenCalledWith ( PI_EVENT_FILTER_PATH , PI_EVENT_FILTER_SOURCE )
125+ const filterWrites = mockWriteFile . mock . calls . filter ( ( [ path ] ) => path === PI_EVENT_FILTER_PATH )
126+ expect ( filterWrites ) . toHaveLength ( 1 )
127+ const filterWrite = mockWriteFile . mock . calls . findIndex (
128+ ( [ path ] ) => path === PI_EVENT_FILTER_PATH
129+ )
130+ expect ( mockRun . mock . invocationCallOrder [ 0 ] ) . toBeLessThan (
131+ mockWriteFile . mock . invocationCallOrder [ filterWrite ]
132+ )
133+ expect ( mockWriteFile . mock . invocationCallOrder [ filterWrite ] ) . toBeLessThan (
134+ mockRun . mock . invocationCallOrder [ 1 ]
135+ )
119136 expect ( onEvent ) . toHaveBeenCalledWith ( { type : 'text' , text : '# Plan\nDo it' } )
120137 expect ( result . totals . finalText ) . toBe ( '# Plan\nDo it' )
121138 expect ( result ) . not . toHaveProperty ( 'changedFiles' )
0 commit comments