@@ -279,6 +279,63 @@ describe("runQaDockerUp", () => {
|
279 | 279 | } |
280 | 280 | }); |
281 | 281 | |
| 282 | +it("rejects explicit host port collisions before touching Docker", async () => { |
| 283 | +const calls: string[] = []; |
| 284 | +const outputDir = await mkdtemp(path.join(os.tmpdir(), "qa-docker-up-")); |
| 285 | + |
| 286 | +try { |
| 287 | +await expect( |
| 288 | +runQaDockerUp( |
| 289 | +{ |
| 290 | +repoRoot: "/repo/openclaw", |
| 291 | + outputDir, |
| 292 | +gatewayPort: 43124, |
| 293 | +qaLabPort: 43124, |
| 294 | +skipUiBuild: true, |
| 295 | +usePrebuiltImage: true, |
| 296 | +}, |
| 297 | +createHealthyDockerDeps(calls), |
| 298 | +), |
| 299 | +).rejects.toThrow( |
| 300 | +"QA Lab gateway and UI host ports must be different. Both resolved to 43124.", |
| 301 | +); |
| 302 | + |
| 303 | +expect(calls).toEqual([]); |
| 304 | +} finally { |
| 305 | +await rm(outputDir, { recursive: true, force: true }); |
| 306 | +} |
| 307 | +}); |
| 308 | + |
| 309 | +it("rejects resolved host port collisions before writing the harness", async () => { |
| 310 | +const outputDir = await mkdtemp(path.join(os.tmpdir(), "qa-docker-up-")); |
| 311 | +const resolveHostPort = vi.fn(async () => 28001); |
| 312 | + |
| 313 | +try { |
| 314 | +await expect( |
| 315 | +runQaDockerUp( |
| 316 | +{ |
| 317 | +repoRoot: "/repo/openclaw", |
| 318 | + outputDir, |
| 319 | +skipUiBuild: true, |
| 320 | +usePrebuiltImage: true, |
| 321 | +}, |
| 322 | +{ |
| 323 | + ...createHealthyDockerDeps([]), |
| 324 | +resolveHostPortImpl: resolveHostPort, |
| 325 | +}, |
| 326 | +), |
| 327 | +).rejects.toThrow( |
| 328 | +"QA Lab gateway and UI host ports must be different. Both resolved to 28001.", |
| 329 | +); |
| 330 | + |
| 331 | +await expect(readFile(path.join(outputDir, "docker-compose.qa.yml"), "utf8")).rejects.toThrow( |
| 332 | +"ENOENT", |
| 333 | +); |
| 334 | +} finally { |
| 335 | +await rm(outputDir, { recursive: true, force: true }); |
| 336 | +} |
| 337 | +}); |
| 338 | + |
282 | 339 | it("falls back to the container IP when the host gateway port is unreachable", async () => { |
283 | 340 | const calls: string[] = []; |
284 | 341 | const fetchCalls: string[] = []; |
|