import { render, screen } from '@testing-library/react' import userEvent from '@testing-library/user-event' import { describe, expect, it, vi } from 'vitest' import { ActionPanel } from './action-panel' import { SHORTCUT_IDS } from '@/state/shortcuts/registry' const { mockShortcut } = vi.hoisted(() => ({ mockShortcut: vi.fn(({ children }: any) =>
{children}
), })) vi.mock('@/components/ui/Shortcut', () => ({ Shortcut: mockShortcut, })) describe('ActionPanel', () => { it('wraps the action button with a shortcut when one is provided', async () => { const user = userEvent.setup() const onClick = vi.fn() render( ) expect(mockShortcut).toHaveBeenCalledWith( expect.objectContaining({ id: SHORTCUT_IDS.JWT_KEYS_CREATE_STANDBY, onTrigger: onClick, options: { enabled: true }, }), undefined ) await user.click(screen.getByRole('button', { name: 'Create Standby Key' })) expect(onClick).toHaveBeenCalled() }) })