mirror of
https://github.com/NanmiCoder/cc-haha
synced 2026-07-19 13:33:35 +08:00
The thinking block title always rendered the static "思考中"/"Thinking" label; isActive only toggled the animated dots. Once thinking finished the dots disappeared but the in-progress text stayed. Switch the label to "已思考"/"Thought" when the block is no longer active. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
43 lines
1.6 KiB
TypeScript
43 lines
1.6 KiB
TypeScript
import { afterEach, beforeEach, describe, expect, it } from 'vitest'
|
|
import { cleanup, render, screen } from '@testing-library/react'
|
|
import '@testing-library/jest-dom'
|
|
|
|
import { ThinkingBlock } from './ThinkingBlock'
|
|
import { useSettingsStore } from '../../stores/settingsStore'
|
|
|
|
describe('ThinkingBlock', () => {
|
|
beforeEach(() => {
|
|
useSettingsStore.setState({ locale: 'zh' })
|
|
})
|
|
|
|
afterEach(() => {
|
|
cleanup()
|
|
useSettingsStore.setState({ locale: 'zh' })
|
|
})
|
|
|
|
it('shows the in-progress label while thinking is active', () => {
|
|
render(<ThinkingBlock content="reasoning..." isActive />)
|
|
expect(screen.getByRole('button')).toHaveTextContent('思考中')
|
|
expect(screen.getByRole('button')).not.toHaveTextContent('已思考')
|
|
})
|
|
|
|
it('shows the done label once thinking has completed', () => {
|
|
render(<ThinkingBlock content="reasoning..." isActive={false} />)
|
|
expect(screen.getByRole('button')).toHaveTextContent('已思考')
|
|
expect(screen.getByRole('button')).not.toHaveTextContent('思考中')
|
|
})
|
|
|
|
it('defaults to the done label when isActive is omitted', () => {
|
|
render(<ThinkingBlock content="reasoning..." />)
|
|
expect(screen.getByRole('button')).toHaveTextContent('已思考')
|
|
})
|
|
|
|
it('localizes both labels in English', () => {
|
|
useSettingsStore.setState({ locale: 'en' })
|
|
const { rerender } = render(<ThinkingBlock content="reasoning..." isActive />)
|
|
expect(screen.getByRole('button')).toHaveTextContent('Thinking')
|
|
rerender(<ThinkingBlock content="reasoning..." isActive={false} />)
|
|
expect(screen.getByRole('button')).toHaveTextContent('Thought')
|
|
})
|
|
})
|