|
2 | 2 | * @vitest-environment jsdom |
3 | 3 | */ |
4 | 4 | import { act } from 'react' |
| 5 | +import { BlockTileView } from '@sim/workflow-renderer' |
5 | 6 | import { createRoot, type Root } from 'react-dom/client' |
6 | 7 | import { renderToStaticMarkup } from 'react-dom/server' |
7 | 8 | import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' |
@@ -71,4 +72,28 @@ describe('TerminalRowButton', () => { |
71 | 72 | expect(html).toContain('>Running</span>') |
72 | 73 | expect(html).not.toContain('<div') |
73 | 74 | }) |
| 75 | + |
| 76 | + it('keeps the complete tile, label, chevron, and status as valid button contents', () => { |
| 77 | + const Icon = ({ className }: { className?: string }) => <svg className={className} /> |
| 78 | + const html = renderToStaticMarkup( |
| 79 | + <TerminalRowButton aria-expanded={false}> |
| 80 | + <span className={ROW_STYLES.content}> |
| 81 | + <BlockTileView as='span' blockType='agent' icon={Icon} bgColor='#33C482' useAccent /> |
| 82 | + <span className={ROW_STYLES.label}>Agent</span> |
| 83 | + <svg aria-hidden='true' /> |
| 84 | + </span> |
| 85 | + <span className={ROW_STYLES.status}> |
| 86 | + <StatusDisplay isRunning isCanceled={false} formattedDuration='-' /> |
| 87 | + </span> |
| 88 | + </TerminalRowButton> |
| 89 | + ) |
| 90 | + const document = new DOMParser().parseFromString(html, 'text/html') |
| 91 | + const button = document.querySelector('button') |
| 92 | + expect(button?.getAttribute('aria-expanded')).toBe('false') |
| 93 | + expect(button?.textContent).toContain('Agent') |
| 94 | + expect(button?.textContent).toContain('Running') |
| 95 | + expect(button?.querySelector('[data-workflow-type-icon="agent"]')).not.toBeNull() |
| 96 | + expect(button?.querySelectorAll('button, a, div')).toHaveLength(0) |
| 97 | + expect(document.body.children).toHaveLength(1) |
| 98 | + }) |
74 | 99 | }) |
0 commit comments