Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { createElement } from 'react'
import { act, create, type ReactTestRenderer } from 'react-test-renderer'
import { afterEach, describe, expect, it, vi } from 'vitest'
import { MobileMarkdown } from './MobileMarkdown'
import { findAllByHostType, findByHostType } from '../test-support/react-test-renderer-host-nodes'
vi.mock('react-native', () => ({
Linking: { openURL: vi.fn() },
Platform: { OS: 'ios' },
Pressable: 'Pressable',
ScrollView: 'ScrollView',
StyleSheet: { create: <T>(styles: T) => styles, hairlineWidth: 1 },
Text: 'Text',
View: 'View'
}))
vi.mock('./pr-sidebar/MermaidDiagram', () => ({ MermaidDiagram: 'MermaidDiagram' }))
vi.mock('./MobileSourceCopyButton', () => ({ MobileSourceCopyButton: 'MobileSourceCopyButton' }))
let renderer: ReactTestRenderer | undefined
afterEach(() => {
renderer?.unmount()
renderer = undefined
vi.restoreAllMocks()
})
function render(content: string): ReactTestRenderer {
act(() => {
renderer = create(createElement(MobileMarkdown, { content }))
})
return renderer!
}
function mermaidCount(tree: ReactTestRenderer): number {
return findAllByHostType(tree.root, 'MermaidDiagram').length
}
function firstMermaid(tree: ReactTestRenderer) {
return findByHostType(tree.root, 'MermaidDiagram')
}
describe('MobileMarkdown mermaid routing', () => {
it('routes a closed mermaid fence to MermaidDiagram', () => {
const tree = render('```mermaid\ngraph TD; A-->B\n```')
expect(mermaidCount(tree)).toBe(1)
})
it('keeps a streaming (unterminated) mermaid fence as raw code', () => {
const tree = render('```mermaid\ngraph TD; A-->B')
expect(mermaidCount(tree)).toBe(0)
})
it('keeps identical sibling diagrams uniquely keyed', () => {
const consoleError = vi.spyOn(console, 'error').mockImplementation(() => {})
const diagram = '```mermaid\ngraph TD; A-->B\n```'
const tree = render(`${diagram}\n\n${diagram}`)
const warnings = consoleError.mock.calls.flat().join(' ')
expect(mermaidCount(tree)).toBe(2)
expect(warnings).not.toContain('same key')
})
it('preserves a completed diagram while later prose streams', () => {
const diagram = '```mermaid\ngraph TD; A-->B\n```'
const tree = render(diagram)
const initial = firstMermaid(tree)
act(() => tree.update(createElement(MobileMarkdown, { content: `${diagram}\n\nNext` })))
expect(firstMermaid(tree)).toBe(initial)
})
it('remounts a diagram when its source changes', () => {
const tree = render('```mermaid\ngraph TD; A-->B\n```')
const initial = firstMermaid(tree)
act(() =>
tree.update(createElement(MobileMarkdown, { content: '```mermaid\ngraph TD; A-->C\n```' }))
)
expect(firstMermaid(tree)).not.toBe(initial)
})
it('does not route other code fences to MermaidDiagram', () => {
const tree = render('```ts\nconst a = 1\n```')
expect(mermaidCount(tree)).toBe(0)
})
})