skillhub/web/src/features/skill/file-tree-node.test.ts
XiaoSeS 8213686601
perf: optimize file tree and preview rendering performance (#240)
* docs: add Maven mirror config and troubleshooting guide for China developers

- Add Aliyun mirror config in server/.mvn/settings.xml
- Update maven-wrapper.properties to use Aliyun mirror for Maven distribution
- Add detailed error messages in Makefile when backend startup fails
- Add troubleshooting section in quickstart.md for China developers
- Add FAQ entry for local development startup issues
- Update README with link to local development guide

* perf: optimize file tree and preview rendering performance

- Add useMemo to cache tree structure and syntax highlighting results
- Add React.memo to FileTreeNodeComponent to prevent unnecessary re-renders
- Add useCallback for stable callback references
- Simplify CSS styles (remove gradients, blur, shadows) to reduce GPU load

Fixes performance issues with file preview lag reported by users.

* test: update test for React.memo wrapped component
2026-04-07 09:54:48 +08:00

21 lines
905 B
TypeScript

import { describe, expect, it } from 'vitest'
import * as mod from './file-tree-node'
/**
* file-tree-node.tsx exports the FileTreeNodeComponent React component.
* It contains two module-private helpers (formatFileSize and getIconComponent)
* that are pure functions but cannot be imported for direct testing.
*
* We verify the module shape so downstream consumers break fast
* if the export contract changes.
*
* Note: FileTreeNodeComponent is wrapped with React.memo, so typeof returns 'object'
* instead of 'function'. We check for both to handle the memo wrapper.
*/
describe('file-tree-node module exports', () => {
it('exports the FileTreeNodeComponent component', () => {
expect(mod.FileTreeNodeComponent).toBeDefined()
// React.memo wraps the component in an object, so typeof is 'object'
expect(['function', 'object']).toContain(typeof mod.FileTreeNodeComponent)
})
})