@@ -18,47 +18,6 @@ async function main() {
1818
1919 let mock : InstanceType < typeof LLMock > | undefined
2020
21- if ( useMock ) {
22- const fixturesDir = path . resolve ( __dirname , "../fixtures" )
23-
24- mock = new LLMock ( {
25- port : 0 , // random free port
26- ...( isRecord && {
27- record : {
28- // OpenRouter is OpenAI-compatible; aimock proxies using the openai provider key.
29- // Use /api (not /api/v1) — aimock appends the request path (/v1/chat/completions)
30- // so including /v1 here would produce a doubled /v1/v1 upstream URL.
31- providers : { openai : "https://openrouter.ai/api" } ,
32- fixturePath : fixturesDir ,
33- } ,
34- } ) ,
35- } )
36-
37- mock . loadFixtureDir ( fixturesDir )
38-
39- if ( ! isRecord ) {
40- // The modes test (switch_mode → ask) triggers a second API call whose last
41- // user message starts with <environment_details> directly — no <user_message>
42- // wrapper. JSON fixtures use substring matching so a bare "<environment_details>"
43- // match would collide with all other requests. A regex anchored to the start
44- // uniquely identifies this post-switch turn.
45- mock . addFixture ( {
46- match : { userMessage : / ^ < e n v i r o n m e n t _ d e t a i l s > / } ,
47- response : {
48- toolCalls : [
49- {
50- name : "attempt_completion" ,
51- arguments : JSON . stringify ( { result : "Switched to ❓ Ask mode as requested." } ) ,
52- id : "call_modes_post_switch_001" ,
53- } ,
54- ] ,
55- } ,
56- } )
57- }
58-
59- await mock . start ( )
60- }
61-
6221 // The folder containing the Extension Manifest package.json
6322 // Passed to `--extensionDevelopmentPath`
6423 const extensionDevelopmentPath = path . resolve ( __dirname , "../../../src" )
@@ -70,6 +29,47 @@ async function main() {
7029 let testWorkspace : string | undefined
7130
7231 try {
32+ if ( useMock ) {
33+ const fixturesDir = path . resolve ( __dirname , "../fixtures" )
34+
35+ mock = new LLMock ( {
36+ port : 0 , // random free port
37+ ...( isRecord && {
38+ record : {
39+ // OpenRouter is OpenAI-compatible; aimock proxies using the openai provider key.
40+ // Use /api (not /api/v1) — aimock appends the request path (/v1/chat/completions)
41+ // so including /v1 here would produce a doubled /v1/v1 upstream URL.
42+ providers : { openai : "https://openrouter.ai/api" } ,
43+ fixturePath : fixturesDir ,
44+ } ,
45+ } ) ,
46+ } )
47+
48+ mock . loadFixtureDir ( fixturesDir )
49+
50+ if ( ! isRecord ) {
51+ // The modes test (switch_mode → ask) triggers a second API call whose last
52+ // user message starts with <environment_details> directly — no <user_message>
53+ // wrapper. JSON fixtures use substring matching so a bare "<environment_details>"
54+ // match would collide with all other requests. A regex anchored to the start
55+ // uniquely identifies this post-switch turn.
56+ mock . addFixture ( {
57+ match : { userMessage : / ^ < e n v i r o n m e n t _ d e t a i l s > / } ,
58+ response : {
59+ toolCalls : [
60+ {
61+ name : "attempt_completion" ,
62+ arguments : JSON . stringify ( { result : "Switched to ❓ Ask mode as requested." } ) ,
63+ id : "call_modes_post_switch_001" ,
64+ } ,
65+ ] ,
66+ } ,
67+ } )
68+ }
69+
70+ await mock . start ( )
71+ }
72+
7373 // Create a temporary workspace folder for tests
7474 testWorkspace = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "roo-test-workspace-" ) )
7575 // Get test filter from command line arguments or environment variable
0 commit comments