Skip to content

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

test(threadList): cover rename cancel during menu close animation

Steven Enamakel39c2f38e5a41
diff --git a/app/src/features/conversations/threadList/ThreadList.test.tsx b/app/src/features/conversations/threadList/ThreadList.test.tsx
index aee1acaa48..fa2ee170ad 100644
--- a/app/src/features/conversations/threadList/ThreadList.test.tsx
+++ b/app/src/features/conversations/threadList/ThreadList.test.tsx
@@ -171,6 +171,46 @@ describe('ThreadList', () => {
expect(screen.getByTestId('thread-row-t1')).toHaveFocus();
});
+ it('cancels a rename while the closed menu is still animating out', async () => {
+ // JSDOM has no CSS animations. Keep the real Radix menu mounted during
+ // its closing animation, as it is in the browser when Escape is pressed.
+ const getComputedStyle = window.getComputedStyle.bind(window);
+ const styleSpy = vi.spyOn(window, 'getComputedStyle').mockImplementation(element => {
+ const style = getComputedStyle(element);
+ if (element.getAttribute('data-slot') === 'aui_thread-list-item-more-content') {
+ Object.defineProperty(style, 'animationName', {
+ get: () => (element.getAttribute('data-state') === 'closed' ? 'menu-out' : 'menu-in'),
+ });
+ }
+ return style;
+ });
+ const onRenameThread = vi.fn(async () => {});
+ const view = renderList({ onRenameThread });
+ try {
+ await userEvent.click(
+ within(screen.getByTestId('thread-row-t1').parentElement!).getByRole('button', {
+ name: 'assistantUi.threadList.moreOptions',
+ })
+ );
+ const menu = await screen.findByRole('menu');
+ await userEvent.click(
+ within(menu).getByRole('menuitem', { name: 'assistantUi.threadList.rename' })
+ );
+ const input = screen.getByTestId('thread-title-input-t1');
+ await userEvent.clear(input);
+ await userEvent.type(input, 'Must not be committed during menu close');
+ expect(menu).toBeInTheDocument();
+ expect(menu).toHaveAttribute('data-state', 'closed');
+ await userEvent.keyboard('{Escape}');
+ await waitFor(() => expect(screen.queryByTestId('thread-title-input-t1')).toBeNull());
+ expect(onRenameThread).not.toHaveBeenCalled();
+ expect(screen.getByTestId('thread-row-t1')).toHaveTextContent('Fix Gmail OAuth');
+ } finally {
+ view.unmount();
+ styleSpy.mockRestore();
+ }
+ });
+
it('puts the working folder name in the row tooltip', () => {
renderList();
expect(screen.getByTestId('thread-row-t4')).toHaveAttribute(