Skip to content

Commit e83f8db

Browse files
test(web): cover unreferenced queued edit records in the open-edit case
AI-assisted; verified with the tests and tools listed above.
1 parent 348402f commit e83f8db

1 file changed

Lines changed: 5 additions & 17 deletions

File tree

‎apps/web/src/components/chat/useQueuedRunEdit.browser.test.tsx‎

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,16 @@ describe("useQueuedRunEdit", () => {
277277
);
278278
});
279279

280-
it("opens an edit with the thread and machine records its mentions refer to", async () => {
280+
it("opens an edit with only the thread and machine records its text still mentions", async () => {
281281
const { hook } = setup();
282282
const thread = threadContextRecord(THREAD_B, "Support Any File Uploads");
283283
const machine = environmentContextRecord(ENV, "Build box");
284+
const unreferenced = threadContextRecord(THREAD_A, "Removed earlier");
284285
const messageId = MessageId.make("message-1");
285286
const text = `wait for ${formatInlineContextReference(threadContextReference(thread))} on ${formatInlineContextReference(environmentContextReference(machine))}`;
286-
const messages = [{ id: messageId, text, context: { version: 1, records: [thread, machine] } }];
287+
const messages = [
288+
{ id: messageId, text, context: { version: 1, records: [thread, machine, unreferenced] } },
289+
];
287290
await using _screen = await render(view(THREAD_A, "queued", hook, messages));
288291

289292
await act(() => requireHook(hook).beginEdit({ runId: RUN, messageId, text, attachments: [] }));
@@ -294,21 +297,6 @@ describe("useQueuedRunEdit", () => {
294297
expect(draft?.environmentContexts).toEqual([machine]);
295298
});
296299

297-
it("opens an edit without records the message text no longer mentions", async () => {
298-
const { hook } = setup();
299-
const unreferenced = threadContextRecord(THREAD_B, "Removed earlier");
300-
const messageId = MessageId.make("message-1");
301-
const text = "plain text";
302-
const messages = [{ id: messageId, text, context: { version: 1, records: [unreferenced] } }];
303-
await using _screen = await render(view(THREAD_A, "queued", hook, messages));
304-
305-
await act(() => requireHook(hook).beginEdit({ runId: RUN, messageId, text, attachments: [] }));
306-
307-
const draft = useComposerDraftStore.getState().getComposerDraft(requireHook(hook).draftTarget);
308-
expect(draft?.prompt).toBe(text);
309-
expect(draft?.threadContexts).toEqual([]);
310-
});
311-
312300
it("saves only the thread mentions still in the edited message", async () => {
313301
const { hook } = setup();
314302
mocks.editQueuedRun.mockResolvedValue({ _tag: "Success" });

0 commit comments

Comments
 (0)