Skip to content

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

test(assistant-ui): update selectors to use data-slot attributes

Steven Enamakel380325703231
diff --git a/app/src/components/assistant-ui/elements/reasoning-panel.test.tsx b/app/src/components/assistant-ui/elements/reasoning-panel.test.tsx
index ef5b383a54..73f31c3bda 100644
--- a/app/src/components/assistant-ui/elements/reasoning-panel.test.tsx
+++ b/app/src/components/assistant-ui/elements/reasoning-panel.test.tsx
@@ -18,10 +18,12 @@ const STEPS = [
];
const trigger = () => screen.getByRole('button');
+// `SwapLabel` stacks the live and resting labels as two layers and hides the
+// inactive one with aria-hidden.
const liveLayer = (root: HTMLElement) =>
- root.querySelector('[data-swap-layer="live"]') as HTMLElement;
+ root.querySelector('[data-slot="reasoning-panel-live-label"]')!.parentElement as HTMLElement;
const restingLayer = (root: HTMLElement) =>
- root.querySelector('[data-swap-layer="resting"]') as HTMLElement;
+ root.querySelector('[data-slot="reasoning-panel-resting-label"]')!.parentElement as HTMLElement;
describe('ReasoningPanel (collapsible)', () => {
it('renders titled steps with markdown bodies when open', () => {
@@ -59,7 +61,7 @@ describe('ReasoningPanel (collapsible)', () => {
expect(restingLayer(root).textContent).toBe('Thought for 12s');
expect(restingLayer(root).getAttribute('aria-hidden')).toBe('false');
expect(liveLayer(root).getAttribute('aria-hidden')).toBe('true');
- expect(container.querySelector('[data-shimmer]')).toBeNull();
+ expect(container.querySelector('.shimmer')).toBeNull();
});
it('toggles open and closed from the trigger', () => {
@@ -87,7 +89,7 @@ describe('ReasoningPanel (collapsible)', () => {
const root = screen.getByTestId('panel');
expect(trigger().getAttribute('aria-expanded')).toBe('true');
expect(liveLayer(root).getAttribute('aria-hidden')).toBe('false');
- const shimmer = container.querySelector('[data-shimmer]');
+ const shimmer = container.querySelector('.shimmer');
expect(shimmer?.textContent).toBe('Planning the fix');
expect(shimmer?.className).toContain('shimmer');
expect(root.querySelector('[data-slot="reasoning-panel-elapsed"]')?.textContent).toBe('4s');
diff --git a/app/src/components/assistant-ui/thread.reasoning.test.tsx b/app/src/components/assistant-ui/thread.reasoning.test.tsx
index a44074ee4a..95ea5a6e3d 100644
--- a/app/src/components/assistant-ui/thread.reasoning.test.tsx
+++ b/app/src/components/assistant-ui/thread.reasoning.test.tsx
@@ -59,7 +59,7 @@ describe('thread reasoning panel', () => {
expect(panels).toHaveLength(1);
const panel = panels[0]!;
expect(panel.getAttribute('data-variant')).toBe('collapsible');
- expect(panel.querySelector('[data-swap-layer="resting"]')?.textContent).toBe('Thought for 12s');
+ expect(panel.querySelector('[data-slot="reasoning-panel-resting-label"]')?.textContent).toBe('Thought for 12s');
const trigger = panel.querySelector('button')!;
expect(trigger.getAttribute('aria-expanded')).toBe('false');
@@ -103,7 +103,7 @@ describe('thread reasoning panel', () => {
};
render(<Harness messages={[user, legacy]} running={false} />);
expect(
- screen.getByTestId('reasoning-panel').querySelector('[data-swap-layer="resting"]')
+ screen.getByTestId('reasoning-panel').querySelector('[data-slot="reasoning-panel-resting-label"]')
?.textContent
).toBe('Thought');
});
diff --git a/app/src/features/conversations/components/InterruptedAnswer.test.tsx b/app/src/features/conversations/components/InterruptedAnswer.test.tsx
index 1a58350f6f..70424d50d0 100644
--- a/app/src/features/conversations/components/InterruptedAnswer.test.tsx
+++ b/app/src/features/conversations/components/InterruptedAnswer.test.tsx
@@ -22,7 +22,7 @@ describe('InterruptedAnswer', () => {
const thinking = screen.getByTestId('interrupted-answer-thinking');
const trigger = thinking.querySelector('button')!;
expect(trigger.getAttribute('aria-expanded')).toBe('false');
- expect(thinking.querySelector('[data-swap-layer="resting"]')?.textContent).toBe('Thought');
+ expect(thinking.querySelector('[data-slot="reasoning-panel-resting-label"]')?.textContent).toBe('Thought');
fireEvent.click(trigger);
expect(block.textContent).toContain('was reasoning about it');
// Marked interrupted rather than presented as a finished answer.
diff --git a/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx b/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
index 9fc13cba18..546c5ab012 100644
--- a/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
+++ b/app/src/features/conversations/components/ProcessingTranscriptView.test.tsx
@@ -91,7 +91,7 @@ describe('ProcessingTranscriptView live thinking', () => {
// sentence's closing period).
expect(live.textContent).toContain('The user wants a week in Kashmir in October');
expect(live.getAttribute('aria-busy')).toBe('true');
- expect(live.querySelector('[data-shimmer]')).not.toBeNull();
+ expect(live.querySelector('.shimmer')).not.toBeNull();
// No settled row for the same thought.
expect(screen.queryByTestId('processing-thinking')).toBeNull();
});
@@ -108,7 +108,7 @@ describe('ProcessingTranscriptView live thinking', () => {
// The rail keeps the trail visible: no disclosure, no live shimmer.
expect(settled.getAttribute('data-variant')).toBe('static');
expect(settled.querySelector('button')).toBeNull();
- expect(settled.querySelector('[data-shimmer]')).toBeNull();
+ expect(settled.querySelector('.shimmer')).toBeNull();
expect(settled.textContent).toContain('Settled reasoning that should stay quiet');
});
@@ -122,7 +122,7 @@ describe('ProcessingTranscriptView live thinking', () => {
const settled = screen.getByTestId('processing-thinking');
// `useT` is mocked to echo keys: the timed "Thought for {n}" key is
// chosen, not the untimed "Thought" fallback.
- expect(settled.querySelector('[data-swap-layer="resting"]')?.textContent).toBe(
+ expect(settled.querySelector('[data-slot="reasoning-panel-resting-label"]')?.textContent).toBe(
'chat.reasoning.thoughtFor'
);
expect(settled.querySelector('[data-slot="reasoning-step-title"]')?.textContent).toBe(