Skip to content

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

test(AgentProcessSourcePanel): add tests for collapsible sources and source count

Steven Enamakel0188fbb9351d
diff --git a/app/src/features/conversations/components/__tests__/AgentProcessSourcePanel.test.tsx b/app/src/features/conversations/components/__tests__/AgentProcessSourcePanel.test.tsx
index 88a30e043d..03bc1e3809 100644
--- a/app/src/features/conversations/components/__tests__/AgentProcessSourcePanel.test.tsx
+++ b/app/src/features/conversations/components/__tests__/AgentProcessSourcePanel.test.tsx
@@ -56,6 +56,40 @@ describe('AgentProcessSourcePanel', () => {
expect(rows[1].textContent).toContain('example.org');
});
+ it('makes the sources list a real disclosure that can be collapsed', async () => {
+ // The heading used to be a plain <h3>, so a long source list had no way to
+ // get out of the way. It is `ai-elements`' Sources (Radix Collapsible) now:
+ // open on mount, with a trigger carrying real expanded state.
+ renderPanel(
+ <AgentProcessSourcePanel
+ open
+ entries={[fetchEntry('e1', 'https://news-gazette.com/a')]}
+ onClose={() => {}}
+ />
+ );
+ const trigger = screen.getByRole('button', { name: /sources/i });
+ expect(trigger).toHaveAttribute('aria-expanded', 'true');
+ expect(screen.getAllByTestId('agent-source-row')).toHaveLength(1);
+
+ await userEvent.click(trigger);
+ expect(trigger).toHaveAttribute('aria-expanded', 'false');
+ expect(screen.queryByTestId('agent-source-row')).toBeNull();
+ });
+
+ it('counts the sources in the disclosure label', () => {
+ renderPanel(
+ <AgentProcessSourcePanel
+ open
+ entries={[
+ fetchEntry('e1', 'https://news-gazette.com/a'),
+ fetchEntry('e2', 'https://example.org/b'),
+ ]}
+ onClose={() => {}}
+ />
+ );
+ expect(screen.getByRole('button', { name: /sources/i }).textContent).toContain('(2)');
+ });
+
it('expands every step row by default (whole run visible at a glance)', () => {
renderPanel(
<AgentProcessSourcePanel