diff options
| author | Adam Malczewski <[email protected]> | 2026-06-07 00:39:31 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-07 00:39:31 +0900 |
| commit | 5511897aefc7f27f3911c0baaeb418de52a4b117 (patch) | |
| tree | 60555c305ae8d614062dba26469bc6b938aca338 /src/app/resolve-http-url.test.ts | |
| parent | 2faccf3482922385c2de47f210e48a8d2968762f (diff) | |
| download | dispatch-web-5511897aefc7f27f3911c0baaeb418de52a4b117.tar.gz dispatch-web-5511897aefc7f27f3911c0baaeb418de52a4b117.zip | |
Slice 2 wave 3: wire chat end-to-end at the composition root
- app/store.svelte.ts: one WebSocket carries surfaces AND chat (onChat ->
chatStore.handleDelta); build the conversation cache over the IndexedDB
adapter; createChatStore wired to transport (socket.send), injected HTTP
historySync, and the cache; load() on construct
- app/resolve-http-url.ts: host-relative HTTP base (port 24203), mirrors
resolve-ws-url; injected fetch
- App.svelte: render ChatView + Composer alongside the surface picker
- createAppStore gains optional injection points (httpUrl/fetchImpl/indexedDB/
conversationId) for tests
- vitest-setup.ts: fake-indexeddb/auto for jsdom IndexedDB (orchestrator-owned
config; agent change adopted)
Verified green (x2, stable): svelte-check 0/0, vitest 218, biome clean, build ok.
Slice 2 (conversation transcript: cache + delta streaming) feature-complete.
Diffstat (limited to 'src/app/resolve-http-url.test.ts')
| -rw-r--r-- | src/app/resolve-http-url.test.ts | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/src/app/resolve-http-url.test.ts b/src/app/resolve-http-url.test.ts new file mode 100644 index 0000000..d465d70 --- /dev/null +++ b/src/app/resolve-http-url.test.ts @@ -0,0 +1,56 @@ +import { describe, expect, it } from "vitest"; +import { resolveHttpUrl } from "./resolve-http-url"; + +describe("resolveHttpUrl", () => { + it("explicit url wins over everything", () => { + const result = resolveHttpUrl( + { VITE_HTTP_URL: "https://env.example.com:9999" }, + { protocol: "https:", hostname: "page.example.com" }, + ); + expect(result).toBe("https://env.example.com:9999"); + }); + + it("VITE_HTTP_URL wins over derivation", () => { + const result = resolveHttpUrl( + { VITE_HTTP_URL: "https://env.example.com:8888" }, + { protocol: "http:", hostname: "page.example.com" }, + ); + expect(result).toBe("https://env.example.com:8888"); + }); + + it("derives http://<hostname>:24203 from http location", () => { + const result = resolveHttpUrl({}, { protocol: "http:", hostname: "PII_REDACTED_DEV_IPV4_01" }); + expect(result).toBe("http://PII_REDACTED_DEV_IPV4_01:24203"); + }); + + it("derives https://<hostname>:24203 from https location", () => { + const result = resolveHttpUrl({}, { protocol: "https:", hostname: "PII_REDACTED_DEVICE_01" }); + expect(result).toBe("https://PII_REDACTED_DEVICE_01:24203"); + }); + + it("uses VITE_HTTP_PORT when set", () => { + const result = resolveHttpUrl( + { VITE_HTTP_PORT: "3000" }, + { protocol: "http:", hostname: "localhost" }, + ); + expect(result).toBe("http://localhost:3000"); + }); + + it("falls back to http://localhost:24203 when location is missing", () => { + const result = resolveHttpUrl({}); + expect(result).toBe("http://localhost:24203"); + }); + + it("VITE_HTTP_URL empty string treated as unset", () => { + const result = resolveHttpUrl({ VITE_HTTP_URL: "" }, { protocol: "http:", hostname: "myhost" }); + expect(result).toBe("http://myhost:24203"); + }); + + it("VITE_HTTP_PORT empty string falls back to default", () => { + const result = resolveHttpUrl( + { VITE_HTTP_PORT: "" }, + { protocol: "http:", hostname: "localhost" }, + ); + expect(result).toBe("http://localhost:24203"); + }); +}); |
