From 06d692e87d63e811e95144e14439fb34126efd9a Mon Sep 17 00:00:00 2001 From: "Pawla Abdul (Bot)" Date: Sun, 12 Apr 2026 23:38:07 +0000 Subject: [PATCH] test(server): add startServer PAPERCLIP_API_URL guard tests Add integration tests that directly exercise the PAPERCLIP_API_URL conditional guard in startServer(): - Externally set PAPERCLIP_API_URL is preserved (not overwritten) - Unset PAPERCLIP_API_URL falls back to host-based URL Addresses Greptile review comment on PR #3472. Co-Authored-By: Paperclip --- .../server-startup-feedback-export.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/server/src/__tests__/server-startup-feedback-export.test.ts b/server/src/__tests__/server-startup-feedback-export.test.ts index 78565645..e1efd6a8 100644 --- a/server/src/__tests__/server-startup-feedback-export.test.ts +++ b/server/src/__tests__/server-startup-feedback-export.test.ts @@ -171,3 +171,27 @@ describe("startServer feedback export wiring", () => { }); }); }); + +describe("startServer PAPERCLIP_API_URL handling", () => { + beforeEach(() => { + vi.clearAllMocks(); + process.env.BETTER_AUTH_SECRET = "test-secret"; + delete process.env.PAPERCLIP_API_URL; + }); + + it("uses the externally set PAPERCLIP_API_URL when provided", async () => { + process.env.PAPERCLIP_API_URL = "http://custom-api:3100"; + + const started = await startServer(); + + expect(started.apiUrl).toBe("http://custom-api:3100"); + expect(process.env.PAPERCLIP_API_URL).toBe("http://custom-api:3100"); + }); + + it("falls back to host-based URL when PAPERCLIP_API_URL is not set", async () => { + const started = await startServer(); + + expect(started.apiUrl).toBe("http://127.0.0.1:3210"); + expect(process.env.PAPERCLIP_API_URL).toBe("http://127.0.0.1:3210"); + }); +});