| ... | ... | @@ -1764,4 +1764,53 @@ describe("MessagesTimeline", () => { |
| 1764 | 1764 | expect(markup).toContain("lucide-circle-alert"); |
| 1765 | 1765 | expect(markup).toContain("text-destructive"); |
| 1766 | 1766 | }); |
| 1767 | |
| 1768 | it("only withholds an expanded tool-call label click while text is selected", async () => { |
| 1769 | vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true); |
| 1770 | vi.stubGlobal("requestAnimationFrame", () => 0); |
| 1771 | vi.stubGlobal("cancelAnimationFrame", () => {}); |
| 1772 | let renderer: ReactTestRenderer | undefined; |
| 1773 | try { |
| 1774 | await act(() => { |
| 1775 | renderer = create( |
| 1776 | <MessagesTimeline |
| 1777 | {...buildProps()} |
| 1778 | timelineEntries={[ |
| 1779 | { |
| 1780 | id: "entry-standalone", |
| 1781 | kind: "work", |
| 1782 | createdAt: MESSAGE_CREATED_AT, |
| 1783 | entry: { |
| 1784 | id: "work-standalone", |
| 1785 | createdAt: MESSAGE_CREATED_AT, |
| 1786 | toolCallId: "call-standalone", |
| 1787 | label: "Run lint", |
| 1788 | tone: "tool", |
| 1789 | itemType: "command_execution", |
| 1790 | command: "pnpm lint", |
| 1791 | toolLifecycleStatus: "completed", |
| 1792 | }, |
| 1793 | }, |
| 1794 | ]} |
| 1795 | />, |
| 1796 | ); |
| 1797 | }); |
| 1798 | await act(() => renderer!.root.findByProps({ "aria-expanded": false }).props.onClick()); |
| 1799 | const label = renderer!.root.findAll( |
| 1800 | (node) => node.type === "span" && String(node.props.className).includes("select-text"), |
| 1801 | )[0]; |
| 1802 | const stopPropagation = vi.fn(); |
| 1803 | // Only the click that ends a selection may be withheld from the row |
| 1804 | // toggle; the plain click has to reach it so the label can collapse. |
| 1805 | for (const isCollapsed of [false, true]) { |
| 1806 | label!.props.onClick({ |
| 1807 | currentTarget: { ownerDocument: { getSelection: () => ({ isCollapsed }) } }, |
| 1808 | stopPropagation, |
| 1809 | }); |
| 1810 | } |
| 1811 | expect(stopPropagation).toHaveBeenCalledTimes(1); |
| 1812 | } finally { |
| 1813 | await act(() => renderer?.unmount()); |
| 1814 | } |
| 1815 | }); |
| 1767 | 1816 | }); |