cc-haha/desktop/vitest.config.ts
程序员阿江(Relakkes) 5b4e224f2e fix(desktop): address shadcn migration review findings
- Prevent EmptySession crash when settings have not loaded: fall back
  to the default permission-mode display and an empty model list, and
  stop undefined models responses from poisoning the settings store
- Sync Tauri terminal hardening with Electron: owner binding, input
  limits, window-destroy session cleanup, malformed config fallback
- Fix Sheet/MobileBottomSheet z-order so dialogs render above sheets
- Migrate ConfirmPopover to the shadcn Button; remove dead legacy
  shared form components and unused mockup pages
- Keep underscores readable in shared diagnostics, redact provider
  models only on secret-scanner hits, clean stale WhatsApp login
  staging dirs, and add recovery hints for corrupt computer-use config
- Token-ize find-in-page highlight colors, restore the indeterminate
  progress slide animation, and tidy a11y/displayName details
2026-07-25 15:07:00 +08:00

50 lines
1.2 KiB
TypeScript

import { defineConfig } from 'vitest/config'
import react from '@vitejs/plugin-react'
import path from 'path'
/**
* Redirect @testing-library/react imports in test files to a wrapper that
* supplies the root TooltipProvider. This keeps individual test files from
* having to repeat the wrapper while still using the familiar testing-library
* import path.
*/
function testLibraryWrapperPlugin() {
return {
name: 'test-library-wrapper',
enforce: 'pre' as const,
transform(code: string, id: string) {
if (!/\.(test|spec)\.(tsx|ts)$/.test(id)) return
if (!code.includes('@testing-library/react')) return
return code.replace(
/from\s+['"]@testing-library\/react['"]/g,
"from '@/test/testing-library'",
)
},
}
}
export default defineConfig({
plugins: [react(), testLibraryWrapperPlugin()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
test: {
environment: 'jsdom',
globals: true,
css: true,
setupFiles: ['./src/test/setup.ts'],
coverage: {
include: ['src/**/*.{ts,tsx}'],
exclude: [
'src/**/*.test.{ts,tsx}',
'src/**/*.d.ts',
'src/types/**',
'src/mocks/**',
'src/vite-env.d.ts',
],
},
},
})