mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-18 13:23:33 +08:00
Long uninterrupted URLs can otherwise force user message bubbles beyond the chat column. The fix keeps the bubble constrained to its parent and allows safe breaks inside continuous URL text, with the same guard applied to markdown paragraphs and links. Constraint: Issue #378 reports desktop chat overflow when a conversation contains a long URL Rejected: Add horizontal scrolling to user messages | this preserves the overflow instead of fixing normal chat readability Confidence: high Scope-risk: narrow Tested: cd desktop && bunx vitest run src/components/chat/UserMessage.test.tsx src/components/chat/MessageList.test.tsx Tested: cd desktop && bun run lint Tested: cd desktop && bun run build Tested: bun run check:desktop Tested: browser layout fixture PASS shell=619 bubbleClient=619 bubbleScroll=619 Not-tested: full root quality gate Related: https://github.com/NanmiCoder/cc-haha/issues/378
22 lines
833 B
TypeScript
22 lines
833 B
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import { describe, expect, it } from 'vitest'
|
|
import { UserMessage } from './UserMessage'
|
|
|
|
describe('UserMessage', () => {
|
|
it('keeps long URLs inside the message bubble', () => {
|
|
const longUrl = `https://cn.bing.com/search?q=${'encoded'.repeat(60)}`
|
|
|
|
const { container } = render(<UserMessage content={longUrl} />)
|
|
|
|
const shell = container.querySelector('[data-message-shell="user"]')
|
|
const bubble = screen.getByText(longUrl)
|
|
|
|
expect(shell?.className).toContain('min-w-0')
|
|
expect(bubble.className).toContain('min-w-0')
|
|
expect(bubble.className).toContain('max-w-full')
|
|
expect(bubble.className).toContain('whitespace-pre-wrap')
|
|
expect(bubble.style.overflowWrap).toBe('anywhere')
|
|
expect(bubble.style.wordBreak).toBe('break-word')
|
|
})
|
|
})
|