Files
hapi/web/src/components/CliOutputBlock.test.tsx
T
Junmo KimandGitHub e52443f4cf feat(web): global word-wrap toggle for code and diff views (#985)
* refactor(web): add per-line shiki line-splitting helper

* feat(web): add global word-wrap toggle for code, markdown, and diff views

* feat(web): add a shaded gutter background behind line numbers

* fix(web): make DiffView compact rows follow the global wrap setting
2026-07-27 19:09:59 +08:00

34 lines
1.5 KiB
TypeScript

import { describe, expect, it } from 'vitest'
import { render, screen } from '@testing-library/react'
import { I18nProvider } from '@/lib/i18n-context'
import { CliOutputBlock } from '@/components/CliOutputBlock'
describe('CliOutputBlock', () => {
it('does not render a nested copy button inside the preview trigger', () => {
render(
<I18nProvider>
<CliOutputBlock text={'<command-name>npm test</command-name><local-command-stdout>ok</local-command-stdout>'} />
</I18nProvider>
)
expect(screen.getByRole('button', { name: /npm test/i })).toBeInTheDocument()
expect(screen.queryByTitle('Copy')).not.toBeInTheDocument()
})
it('does not render a nested wrap toggle button inside the preview trigger', () => {
// The preview CodeBlock renders inside a DialogTrigger <button>, so
// its wrap toggle <button> must be suppressed to avoid nesting
// interactive elements (invalid HTML / hydration violation).
render(
<I18nProvider>
<CliOutputBlock text={'<command-name>npm test</command-name><local-command-stdout>ok</local-command-stdout>'} />
</I18nProvider>
)
// The wrap toggle is the only button carrying aria-pressed; asserting
// its absence by role avoids coupling to the localized title.
expect(screen.queryByRole('button', { pressed: false })).not.toBeInTheDocument()
expect(screen.queryByRole('button', { pressed: true })).not.toBeInTheDocument()
})
})