@@ -46,6 +46,11 @@ vi.mock("@dotenvx/dotenvx", () => ({
4646 config : vi . fn ( ) ,
4747} ) )
4848
49+ // Mock fs so the extension module can safely check for optional .env.
50+ vi . mock ( "fs" , ( ) => ( {
51+ existsSync : vi . fn ( ) . mockReturnValue ( false ) ,
52+ } ) )
53+
4954const mockBridgeOrchestratorDisconnect = vi . fn ( ) . mockResolvedValue ( undefined )
5055
5156const mockCloudServiceInstance = {
@@ -238,6 +243,36 @@ describe("extension.ts", () => {
238243 authStateChangedHandler = undefined
239244 } )
240245
246+ test ( "does not call dotenvx.config when optional .env does not exist" , async ( ) => {
247+ vi . resetModules ( )
248+ vi . clearAllMocks ( )
249+
250+ const fs = await import ( "fs" )
251+ vi . mocked ( fs . existsSync ) . mockReturnValue ( false )
252+
253+ const dotenvx = await import ( "@dotenvx/dotenvx" )
254+
255+ const { activate } = await import ( "../extension" )
256+ await activate ( mockContext )
257+
258+ expect ( dotenvx . config ) . not . toHaveBeenCalled ( )
259+ } )
260+
261+ test ( "calls dotenvx.config when optional .env exists" , async ( ) => {
262+ vi . resetModules ( )
263+ vi . clearAllMocks ( )
264+
265+ const fs = await import ( "fs" )
266+ vi . mocked ( fs . existsSync ) . mockReturnValue ( true )
267+
268+ const dotenvx = await import ( "@dotenvx/dotenvx" )
269+
270+ const { activate } = await import ( "../extension" )
271+ await activate ( mockContext )
272+
273+ expect ( dotenvx . config ) . toHaveBeenCalledTimes ( 1 )
274+ } )
275+
241276 test ( "authStateChangedHandler calls BridgeOrchestrator.disconnect when logged-out event fires" , async ( ) => {
242277 const { CloudService, BridgeOrchestrator } = await import ( "@roo-code/cloud" )
243278
0 commit comments