|
@@ -46,6 +46,11 @@ vi.mock("@dotenvx/dotenvx", () => ({
|
|
|
config: vi.fn(),
|
|
config: vi.fn(),
|
|
|
}))
|
|
}))
|
|
|
|
|
|
|
|
|
|
+// Mock fs so the extension module can safely check for optional .env.
|
|
|
|
|
+vi.mock("fs", () => ({
|
|
|
|
|
+ existsSync: vi.fn().mockReturnValue(false),
|
|
|
|
|
+}))
|
|
|
|
|
+
|
|
|
const mockBridgeOrchestratorDisconnect = vi.fn().mockResolvedValue(undefined)
|
|
const mockBridgeOrchestratorDisconnect = vi.fn().mockResolvedValue(undefined)
|
|
|
|
|
|
|
|
const mockCloudServiceInstance = {
|
|
const mockCloudServiceInstance = {
|
|
@@ -238,6 +243,36 @@ describe("extension.ts", () => {
|
|
|
authStateChangedHandler = undefined
|
|
authStateChangedHandler = undefined
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
|
|
+ test("does not call dotenvx.config when optional .env does not exist", async () => {
|
|
|
|
|
+ vi.resetModules()
|
|
|
|
|
+ vi.clearAllMocks()
|
|
|
|
|
+
|
|
|
|
|
+ const fs = await import("fs")
|
|
|
|
|
+ vi.mocked(fs.existsSync).mockReturnValue(false)
|
|
|
|
|
+
|
|
|
|
|
+ const dotenvx = await import("@dotenvx/dotenvx")
|
|
|
|
|
+
|
|
|
|
|
+ const { activate } = await import("../extension")
|
|
|
|
|
+ await activate(mockContext)
|
|
|
|
|
+
|
|
|
|
|
+ expect(dotenvx.config).not.toHaveBeenCalled()
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ test("calls dotenvx.config when optional .env exists", async () => {
|
|
|
|
|
+ vi.resetModules()
|
|
|
|
|
+ vi.clearAllMocks()
|
|
|
|
|
+
|
|
|
|
|
+ const fs = await import("fs")
|
|
|
|
|
+ vi.mocked(fs.existsSync).mockReturnValue(true)
|
|
|
|
|
+
|
|
|
|
|
+ const dotenvx = await import("@dotenvx/dotenvx")
|
|
|
|
|
+
|
|
|
|
|
+ const { activate } = await import("../extension")
|
|
|
|
|
+ await activate(mockContext)
|
|
|
|
|
+
|
|
|
|
|
+ expect(dotenvx.config).toHaveBeenCalledTimes(1)
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
test("authStateChangedHandler calls BridgeOrchestrator.disconnect when logged-out event fires", async () => {
|
|
test("authStateChangedHandler calls BridgeOrchestrator.disconnect when logged-out event fires", async () => {
|
|
|
const { CloudService, BridgeOrchestrator } = await import("@roo-code/cloud")
|
|
const { CloudService, BridgeOrchestrator } = await import("@roo-code/cloud")
|
|
|
|
|
|