|
| 1 | +import type { ServerConfig, ServerConfigStreamEvent } from "@t3tools/contracts"; |
| 2 | +import * as Option from "effect/Option"; |
1 | 3 | import { describe, expect, it } from "vite-plus/test"; |
2 | 4 |
|
3 | | -import { reuseUnchanged } from "./serverConfigProjection.ts"; |
| 5 | +import { applyServerConfigProjection, reuseUnchanged } from "./serverConfigProjection.ts"; |
4 | 6 |
|
5 | 7 | describe("reuseUnchanged", () => { |
6 | 8 | const provider = (checkedAt: string, skills: ReadonlyArray<string>) => ({ |
@@ -38,3 +40,23 @@ describe("reuseUnchanged", () => { |
38 | 40 | expect(dropped).toEqual({ a: 1 }); |
39 | 41 | }); |
40 | 42 | }); |
| 43 | + |
| 44 | +describe("applyServerConfigProjection snapshot", () => { |
| 45 | + const snapshot = (checkedAt: string) => |
| 46 | + ({ |
| 47 | + type: "snapshot", |
| 48 | + config: { |
| 49 | + environment: { capabilities: {} }, |
| 50 | + providers: [{ instanceId: "claude", checkedAt, skills: [{ name: "review" }] }], |
| 51 | + }, |
| 52 | + }) as unknown as ServerConfigStreamEvent; |
| 53 | + const providersOf = (projection: ReturnType<typeof applyServerConfigProjection>) => |
| 54 | + (Option.getOrThrow(projection).config as ServerConfig).providers; |
| 55 | + |
| 56 | + it("keeps unchanged skills when a reconnect re-sends the config", () => { |
| 57 | + const first = applyServerConfigProjection(Option.none(), snapshot("a")); |
| 58 | + const second = applyServerConfigProjection(first, snapshot("b")); |
| 59 | + expect(providersOf(second)[0]!.checkedAt).toBe("b"); |
| 60 | + expect(providersOf(second)[0]!.skills).toBe(providersOf(first)[0]!.skills); |
| 61 | + }); |
| 62 | +}); |
0 commit comments