| 1 | import { scopeThreadRef } from "@t3tools/client-runtime/environment"; |
| 2 | import { EnvironmentId, ThreadId } from "@t3tools/contracts"; |
| 3 | import { describe, expect, it } from "vite-plus/test"; |
| 4 | |
| 5 | import { resolveThreadDetailRef } from "./entities"; |
| 6 | |
| 7 | const threadRef = scopeThreadRef(EnvironmentId.make("environment-1"), ThreadId.make("thread-1")); |
| 8 | |
| 9 | describe("resolveThreadDetailRef", () => { |
| 10 | it("does not subscribe to a reserved draft thread before it enters the shell index", () => { |
| 11 | expect( |
| 12 | resolveThreadDetailRef(threadRef, { |
| 13 | shellExists: false, |
| 14 | waitForShell: true, |
| 15 | }), |
| 16 | ).toBeNull(); |
| 17 | }); |
| 18 | |
| 19 | it("subscribes once the reserved draft thread enters the shell index", () => { |
| 20 | expect( |
| 21 | resolveThreadDetailRef(threadRef, { |
| 22 | shellExists: true, |
| 23 | waitForShell: true, |
| 24 | }), |
| 25 | ).toBe(threadRef); |
| 26 | }); |
| 27 | |
| 28 | it("keeps direct server-thread lookups enabled when the shell has not loaded it", () => { |
| 29 | expect( |
| 30 | resolveThreadDetailRef(threadRef, { |
| 31 | shellExists: false, |
| 32 | waitForShell: false, |
| 33 | }), |
| 34 | ).toBe(threadRef); |
| 35 | }); |
| 36 | }); |