Main's rewritten test_tui_npm_install.py tests call _make_tui_argv expecting the Ink/npm flow unconditionally; with the dual-engine dispatch merged in, _resolve_tui_engine() auto-selects opentui whenever ui-opentui/dist is built in the repo, routing the call away from the path under test (first subprocess became 'node --version' instead of 'npm run build'). Pin the engine to ink via an autouse fixture, mirroring the existing pinning precedent in test_tui_resume_flow.py.
51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { cleanup, render, screen } from '@testing-library/react'
|
|
import { afterEach, describe, expect, it, vi } from 'vitest'
|
|
|
|
import { I18nProvider } from '@/i18n'
|
|
|
|
import { ComposerTriggerPopover } from './trigger-popover'
|
|
|
|
function renderPopover(kind: '@' | '/', loading = false) {
|
|
const onHover = vi.fn()
|
|
const onPick = vi.fn()
|
|
|
|
const rendered = render(
|
|
<I18nProvider configClient={null} initialLocale="zh">
|
|
<ComposerTriggerPopover activeIndex={0} items={[]} kind={kind} loading={loading} onHover={onHover} onPick={onPick} />
|
|
</I18nProvider>
|
|
)
|
|
|
|
return { ...rendered, onHover, onPick }
|
|
}
|
|
|
|
describe('ComposerTriggerPopover i18n', () => {
|
|
afterEach(() => {
|
|
cleanup()
|
|
})
|
|
|
|
it('renders localized empty lookup copy for @ references', () => {
|
|
const { container } = renderPopover('@')
|
|
|
|
expect(screen.getByText('没有匹配项。')).toBeTruthy()
|
|
expect(container.textContent).toContain('试试')
|
|
expect(container.textContent).toContain('@file:')
|
|
expect(container.textContent).toContain('或')
|
|
expect(container.textContent).toContain('@folder:')
|
|
})
|
|
|
|
it('renders localized loading copy for slash commands', () => {
|
|
renderPopover('/', true)
|
|
|
|
// While loading the popover shows only the spinner + loading copy — the
|
|
// `/help` empty-state hint is reserved for the resolved (not-loading) state.
|
|
expect(screen.getByText('查找中…')).toBeTruthy()
|
|
})
|
|
|
|
it('renders the slash empty-state hint when not loading', () => {
|
|
const { container } = renderPopover('/')
|
|
|
|
expect(screen.getByText('没有匹配项。')).toBeTruthy()
|
|
expect(container.textContent).toContain('/help')
|
|
})
|
|
})
|