Skip to content

Commit e8dfe7c

Browse files
Alb11747codex
andcommitted
test(server): observe prompt suggestion before clearing it
Wait for the initial stream value before clearing the suggestion, so the regression cannot pass with only the cleared value. Co-Authored-By: GPT-6.1 Sol at high effort <[email protected]> Co-Authored-By: GPT-6.1 Sol at xhigh effort, independent review <[email protected]>
1 parent 7936584 commit e8dfe7c

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

‎apps/server/src/provider/PromptSuggestions.test.ts‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { describe, expect, it } from "@effect/vitest";
22
import { RunId, ThreadId } from "@t3tools/contracts";
3+
import * as Deferred from "effect/Deferred";
34
import * as Effect from "effect/Effect";
45
import * as Fiber from "effect/Fiber";
56
import * as Stream from "effect/Stream";
@@ -37,16 +38,23 @@ describe("PromptSuggestions", () => {
3738
yield* suggestions.claim(threadId, runId);
3839
yield* suggestions.claim(otherThreadId, runId);
3940
yield* suggestions.publish(threadId, suggestion);
41+
const observedSuggestion = yield* Deferred.make<void>();
4042
const collected = yield* suggestions.stream(threadId).pipe(
43+
Stream.tap((value) =>
44+
value?.id === suggestion.id
45+
? Deferred.succeed(observedSuggestion, undefined)
46+
: Effect.void,
47+
),
4148
Stream.takeUntil((value) => value === null),
4249
Stream.runCollect,
4350
Effect.forkChild,
4451
);
45-
yield* Effect.yieldNow;
52+
yield* Deferred.await(observedSuggestion);
4653
yield* suggestions.publish(otherThreadId, { id: "suggestion-2", runId, text: "Elsewhere" });
4754
yield* suggestions.clear(threadId, runId);
4855

4956
const values = yield* Fiber.join(collected);
57+
expect(values[0]).toEqual(suggestion);
5058
expect(values.at(-1)).toBeNull();
5159
expect(values.some((value) => value?.id === "suggestion-2")).toBe(false);
5260
}),

0 commit comments

Comments
 (0)