Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

threadTitleRegeneration.test.ts

37 lines1.4 KB

1import { describe, expect, it } from "@effect/vitest";
2import { CommandId } from "@t3tools/contracts";
3import * as Effect from "effect/Effect";
4import * as Fiber from "effect/Fiber";
5import { Atom, AtomRegistry } from "effect/reactivity";
6​
7import { v2ShellSnapshot, v2ThreadShell } from "./orchestrationV2TestFixtures.ts";
8import { waitForTitleRegenerationOutcome } from "./threadTitleRegeneration.ts";
9​
10describe("waiting for title regeneration", () => {
11 it.effect("stops waiting when the shell discards the request's history", () =>
12 Effect.gen(function* () {
13 const registry = AtomRegistry.make();
14 yield* Effect.addFinalizer(() => Effect.sync(() => registry.dispose()));
15 const historyInvalidated = Atom.make(false);
16 const result = yield* Effect.forkChild(
17 waitForTitleRegenerationOutcome(
18 registry,
19 {
20 snapshot: Atom.make(v2ShellSnapshot),
21 disconnected: Atom.make(false),
22 historyInvalidated,
23 },
24 {
25 threadId: v2ThreadShell.id,
26 requestId: CommandId.make("restore-title"),
27 sequence: v2ShellSnapshot.snapshotSequence + 1,
28 },
29 ),
30 { startImmediately: true },
31 );
32 expect(result.pollUnsafe()).toBeUndefined();
33 registry.set(historyInvalidated, true);
34 expect(yield* Fiber.join(result)).toBeNull();
35 }),
36 );
37});