Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(assistant-ui): replace raw promise waits with vi.waitFor in slot tests

Steven Enamakel513dd163205b
diff --git a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
index 5ad393050b..01073e81f8 100644
--- a/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
+++ b/app/src/features/conversations/components/AssistantUiChat.slots.test.tsx
@@ -153,7 +153,7 @@ describe('assistant-ui composer slots', () => {
expect(dataTransfer.dropEffect).toBe('none');
});
- it('takes a file dropped anywhere over the open thread, not just the composer', () => {
+ it('takes a file dropped anywhere over the open thread, not just the composer', async () => {
const store = buildStore();
const onAttachFiles = vi.fn(() => Promise.resolve());
render(
@@ -176,7 +176,7 @@ describe('assistant-ui composer slots', () => {
});
expect(drop).toBe(false); // default (navigate to the file) cancelled
- expect(onAttachFiles).toHaveBeenCalledWith([file]);
+ await vi.waitFor(() => expect(onAttachFiles).toHaveBeenCalledWith([file]));
expect(composerShell().getAttribute('data-dragging')).toBeNull();
});
@@ -199,15 +199,13 @@ describe('assistant-ui composer slots', () => {
});
drop('first.txt');
- await Promise.resolve();
- expect(onAttachFiles).toHaveBeenCalledTimes(1);
+ await vi.waitFor(() => expect(onAttachFiles).toHaveBeenCalledTimes(1));
drop('second.txt');
await Promise.resolve();
expect(onAttachFiles).toHaveBeenCalledTimes(1);
finishFirst();
await firstFinished;
- await Promise.resolve();
- expect(onAttachFiles).toHaveBeenCalledTimes(2);
+ await vi.waitFor(() => expect(onAttachFiles).toHaveBeenCalledTimes(2));
});
});