()
| 179 | } |
| 180 | |
| 181 | async function testCreateSiteMirrorsUiFollowUpActions() { |
| 182 | resetManagers() |
| 183 | const forkManager = new FakeForkManager() |
| 184 | const nginx = makeVersion('nginx', '1.29.0') |
| 185 | forkManager.installedByFlag.nginx = [nginx] |
| 186 | ServiceVersionManager.updateCache({ nginx: [nginx] }) |
| 187 | ServiceProcessManager.addPid('nginx', '1001', nginx) |
| 188 | |
| 189 | const payloads: any[] = [] |
| 190 | ServiceVersionManager.onMcpNotify((payload) => { |
| 191 | payloads.push(payload) |
| 192 | }) |
| 193 | |
| 194 | const createdHosts = [{ id: 1, name: 'demo.test', root: 'F:/www/demo', type: 'php' }] |
| 195 | const originalSend = forkManager.send.bind(forkManager) |
| 196 | forkManager.send = ((module: string, fn: string, ...args: any[]) => { |
| 197 | forkManager.calls.push({ module, fn, args }) |
| 198 | if (module === 'host' && fn === 'handleHost') { |
| 199 | return createSendResult({ code: 0, data: { host: createdHosts } }) |
| 200 | } |
| 201 | if (module === 'host' && fn === 'writeHosts') { |
| 202 | return createSendResult({ code: 0, data: true }) |
| 203 | } |
| 204 | forkManager.calls.pop() |
| 205 | return originalSend(module, fn, ...args) |
| 206 | }) as any |
| 207 | |
| 208 | const tools = new MCPTools( |
| 209 | forkManager as any, |
| 210 | new FakeMcpConfigManager() as any, |
| 211 | new FakeAppConfig({ |
| 212 | setup: { |
| 213 | hosts: { |
| 214 | write: true, |
| 215 | ipv6: false |
| 216 | } |
| 217 | } |
| 218 | }) as any |
| 219 | ) |
| 220 | |
| 221 | await tools.createSite({ name: 'demo.test', root: 'F:/www/demo' }) |
| 222 | |
| 223 | assert.equal(forkManager.calls[0]?.module, 'host') |
| 224 | assert.equal(forkManager.calls[0]?.fn, 'handleHost') |
| 225 | assert.equal(forkManager.calls[0]?.args[0]?.useSSL, true) |
| 226 | assert.equal(forkManager.calls[0]?.args[0]?.autoSSL, true) |
| 227 | assert.deepEqual( |
| 228 | forkManager.calls.map((item) => `${item.module}:${item.fn}`), |
| 229 | ['host:handleHost', 'nginx:stopService', 'nginx:startService', 'host:writeHosts'] |
| 230 | ) |
| 231 | assert.deepEqual(forkManager.calls[3]?.args, [true, false]) |
| 232 | assert.equal(payloads.length, 1) |
| 233 | assert.equal(payloads[0]?.type, 'host-list-changed') |
| 234 | assert.equal(payloads[0]?.hosts?.[0]?.name, 'demo.test') |
| 235 | } |
| 236 | |
| 237 | async function testUpdateSiteMirrorsUiEditableFields() { |
| 238 | resetManagers() |
no test coverage detected