Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
import type { TestRunMenuRef, TriggerOption } from '../test-run-menu'
import { fireEvent, render, screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import * as React from 'react'
import TestRunMenu, { TriggerType } from '../test-run-menu'
const createOption = (overrides: Partial<TriggerOption> = {}): TriggerOption => ({
id: 'user-input',
type: TriggerType.UserInput,
name: 'User Input',
icon: <span>icon</span>,
enabled: true,
...overrides,
})
describe('TestRunMenu', () => {
it('should run the only enabled option directly and preserve the child click handler', async () => {
const user = userEvent.setup()
const onSelect = vi.fn()
const originalOnClick = vi.fn()
render(
<TestRunMenu
options={{
userInput: createOption(),
triggers: [],
}}
onSelect={onSelect}
>
<button onClick={originalOnClick}>Run now</button>
</TestRunMenu>,
)
await user.click(screen.getByRole('button', { name: 'Run now' }))
expect(originalOnClick).toHaveBeenCalledTimes(1)
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: 'user-input' }))
})
it('selects Run All through the public toggle and menu shortcut', async () => {
const user = userEvent.setup()
const onSelect = vi.fn()
const Harness = () => {
const ref = React.useRef<TestRunMenuRef>(null)
return (
<>
<button onClick={() => ref.current?.toggle()}>Toggle via ref</button>
<TestRunMenu
ref={ref}
options={{
userInput: createOption(),
runAll: createOption({ id: 'run-all', type: TriggerType.All, name: 'Run All' }),
triggers: [
createOption({
id: 'trigger-1',
type: TriggerType.Webhook,
name: 'Webhook Trigger',
}),
],
}}
onSelect={onSelect}
>
<button>Open menu</button>
</TestRunMenu>
</>
)
}
render(<Harness />)
await user.click(screen.getByRole('button', { name: 'Toggle via ref' }))
expect(screen.getByRole('menu')).toBeInTheDocument()
fireEvent.keyDown(screen.getByRole('menu'), { key: '0' })
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: 'run-all' }))
})
it('keeps menu accelerators local and ignores composition and modified keys', async () => {
const user = userEvent.setup()
const onSelect = vi.fn()
render(
<TestRunMenu
options={{
userInput: createOption(),
triggers: [createOption({ id: 'trigger', name: 'Webhook', type: TriggerType.Webhook })],
}}
onSelect={onSelect}
>
<button>Open menu</button>
</TestRunMenu>,
)
await user.click(screen.getByRole('button', { name: 'Open menu' }))
const menu = screen.getByRole('menu')
fireEvent.keyDown(document.body, { key: '0' })
fireEvent.keyDown(menu, { key: '0', isComposing: true })
fireEvent.keyDown(menu, { key: '0', ctrlKey: true })
fireEvent.keyDown(menu, { key: '0', repeat: true })
expect(onSelect).not.toHaveBeenCalled()
fireEvent.keyDown(menu, { key: '0' })
expect(onSelect).toHaveBeenCalledWith(expect.objectContaining({ id: 'trigger' }))
})
it('should ignore disabled options in the rendered menu', async () => {
const user = userEvent.setup()
render(
<TestRunMenu
options={{
userInput: createOption({ enabled: false }),
runAll: createOption({ id: 'run-all', type: TriggerType.All, name: 'Run All' }),
triggers: [
createOption({ id: 'trigger-1', type: TriggerType.Webhook, name: 'Webhook Trigger' }),
],
}}
onSelect={vi.fn()}
>
<button>Open menu</button>
</TestRunMenu>,
)
await user.click(screen.getByRole('button', { name: 'Open menu' }))
expect(screen.queryByText('User Input')).not.toBeInTheDocument()
expect(screen.getByText('Webhook Trigger')).toBeInTheDocument()
})
})