mirror of
https://github.com/NanmiCoder/claude-code-haha.git
synced 2026-10-10 11:53:10 +08:00
e9b53f6848
The shadcn migration (ad597ffe) and its follow-up (5b4e224f) were mega-commits: only ~16% of the insertions were UI work. Rolling either one back wholesale also deletes ~3400 lines of unrelated server, Electron, and store hardening -- and because each of those changes shipped with its own tests, the suite stays green while the hardening silently disappears. This rolls back the UI layer only. Reverted (back toc2774fc1): - desktop/src/components, pages, features, theme, i18n - components/ui/**, components.json, src/lib/utils.ts (cn helper) - radix-ui, class-variance-authority, tailwind-merge deps - src-tauri/src/lib.rs hardening: dead code, nothing compiles it (no @tauri-apps dep, no cargo invocation anywhere, and scripts/pr/release-workflow.test.ts asserts Tauri's absence) Kept (identical to main): - src/** -- WhatsApp authDir escape allowing arbitrary recursive directory removal, computer-use tier bypass granting every pre-authorized app full tier, plugin uninstall keepData inversion that deleted data when asked to keep it, plugin project-scope writing to the sidecar cwd, diagnostics share leaking provider config, memory API TOCTOU plus atomic writes - desktop/electron/** -- PTY leak on renderer destruction, IPC boundary validation rejecting NaN and unbounded input - desktop/src/stores/** -- request-id race guards - desktop/src/api, lib/desktopHost -- kept in step with the stores Follows main'sb64069a3in dropping the installed-skills overview. Updated two memorySettings assertions to expect the optimistic-lock fields the retained memory store sends. check:desktop pass (lint clean, 225 files / 2519 passed / 1 skipped, build ok). check:server pass (224 files / 2375 passed / 0 failed).
50 lines
1.5 KiB
TypeScript
50 lines
1.5 KiB
TypeScript
import { render, screen } from '@testing-library/react'
|
|
import '@testing-library/jest-dom'
|
|
import { describe, expect, it, vi, beforeEach, afterEach } from 'vitest'
|
|
|
|
import { useSettingsStore } from '../stores/settingsStore'
|
|
import { ErrorBoundary } from './ErrorBoundary'
|
|
import { reportReactError } from '../lib/diagnosticsCapture'
|
|
|
|
vi.mock('../lib/diagnosticsCapture', () => ({
|
|
reportReactError: vi.fn(),
|
|
}))
|
|
|
|
vi.mock('./doctor/DoctorPanel', () => ({
|
|
DoctorPanel: ({ compact }: { compact?: boolean }) => (
|
|
<div data-testid="doctor-panel">{compact ? 'compact doctor' : 'doctor'}</div>
|
|
),
|
|
}))
|
|
|
|
function CrashingChild(): never {
|
|
throw new Error('boom')
|
|
}
|
|
|
|
describe('ErrorBoundary', () => {
|
|
let consoleErrorSpy: ReturnType<typeof vi.spyOn>
|
|
|
|
beforeEach(() => {
|
|
useSettingsStore.setState({ locale: 'en' })
|
|
vi.clearAllMocks()
|
|
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {})
|
|
})
|
|
|
|
afterEach(() => {
|
|
consoleErrorSpy.mockRestore()
|
|
})
|
|
|
|
it('shows retry and compact Doctor fallback when a child crashes', () => {
|
|
render(
|
|
<ErrorBoundary>
|
|
<CrashingChild />
|
|
</ErrorBoundary>,
|
|
)
|
|
|
|
expect(screen.getByText('Something went wrong.')).toBeInTheDocument()
|
|
expect(screen.getByText('The error was recorded in Diagnostics.')).toBeInTheDocument()
|
|
expect(screen.getByRole('button', { name: 'Retry' })).toBeInTheDocument()
|
|
expect(screen.getByTestId('doctor-panel')).toHaveTextContent('compact doctor')
|
|
expect(reportReactError).toHaveBeenCalled()
|
|
})
|
|
})
|