(
options: CreateHeadlessEnvironmentOptions = {}
)
| 92 | } |
| 93 | |
| 94 | export async function createHeadlessEnvironment( |
| 95 | options: CreateHeadlessEnvironmentOptions = {} |
| 96 | ): Promise<HeadlessEnvironment> { |
| 97 | const { rootDir, dispose: disposeRootDir } = await establishRootDir(options.rootDir); |
| 98 | |
| 99 | const config = new Config(rootDir); |
| 100 | |
| 101 | const { window: mockWindow, sentEvents } = createMockBrowserWindow(); |
| 102 | |
| 103 | const mockedElectron = createIPCMock(); |
| 104 | assertMockedElectron(mockedElectron); |
| 105 | const mockIpcMainModule = mockedElectron.ipcMain; |
| 106 | const mockIpcRendererModule = mockedElectron.ipcRenderer; |
| 107 | |
| 108 | const services = new ServiceContainer(config); |
| 109 | // Headless bench environment has no interactive host-key dialog |
| 110 | setOpenSSHHostKeyPolicyMode("headless-fallback"); |
| 111 | await services.initialize(); |
| 112 | services.windowService.setMainWindow(mockWindow); |
| 113 | |
| 114 | const dispose = async () => { |
| 115 | sentEvents.length = 0; |
| 116 | await disposeRootDir(); |
| 117 | }; |
| 118 | |
| 119 | return { |
| 120 | config, |
| 121 | services, |
| 122 | mockIpcMain: mockIpcMainModule, |
| 123 | mockIpcRenderer: mockIpcRendererModule, |
| 124 | mockWindow, |
| 125 | sentEvents, |
| 126 | rootDir, |
| 127 | dispose, |
| 128 | }; |
| 129 | } |
nothing calls this directly
no test coverage detected