chore: 保存工作副本——客户端授权新契约(双端点/验签/令牌/周检)与桌面会话可靠性改进
This commit is contained in:
1 parent
f71eef0eba
commit
ae6093c9b3
163 files changed
+4911
-2494
No files matched your search
@@ -0,0 +1,60 @@
|
||||
import { render, screen } from '@testing-library/react'
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import ErrorBoundary from '../../src/components/common/ErrorBoundary'
|
||||
import i18n from '../../src/i18n'
|
||||
|
||||
function Boom(): never {
|
||||
throw new Error('pane-crash')
|
||||
}
|
||||
|
||||
describe('ErrorBoundary', () => {
|
||||
beforeEach(() => {
|
||||
vi.spyOn(console, 'error').mockImplementation(() => {})
|
||||
})
|
||||
|
||||
afterEach(async () => {
|
||||
await i18n.changeLanguage('zh-CN')
|
||||
vi.restoreAllMocks()
|
||||
})
|
||||
|
||||
it('shows compact pane copy in Chinese', async () => {
|
||||
await i18n.changeLanguage('zh-CN')
|
||||
render(
|
||||
<ErrorBoundary compact>
|
||||
<Boom />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
expect(screen.getByText(i18n.t('common:error.bodyPane'))).toBeVisible()
|
||||
expect(screen.getByRole('button', { name: i18n.t('common:error.retryPane') })).toBeVisible()
|
||||
})
|
||||
|
||||
it('shows compact pane copy in English', async () => {
|
||||
await i18n.changeLanguage('en')
|
||||
render(
|
||||
<ErrorBoundary compact>
|
||||
<Boom />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
|
||||
expect(screen.getByText('This tab hit an unexpected problem. Other tabs still work.')).toBeVisible()
|
||||
expect(screen.getByRole('button', { name: 'Retry this tab' })).toBeVisible()
|
||||
})
|
||||
|
||||
it('clears the captured error when resetKey changes', async () => {
|
||||
await i18n.changeLanguage('zh-CN')
|
||||
const { rerender } = render(
|
||||
<ErrorBoundary compact resetKey="tab-a">
|
||||
<Boom />
|
||||
</ErrorBoundary>
|
||||
)
|
||||
expect(screen.getByText(i18n.t('common:error.bodyPane'))).toBeVisible()
|
||||
|
||||
rerender(
|
||||
<ErrorBoundary compact resetKey="tab-b">
|
||||
<div>ok-pane</div>
|
||||
</ErrorBoundary>
|
||||
)
|
||||
expect(screen.getByText('ok-pane')).toBeVisible()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user