Skip to content

Commit 1604e51

Browse files
committed
update readme & coverage excludes
1 parent 2da908d commit 1604e51

File tree

2 files changed

+125
-8
lines changed

2 files changed

+125
-8
lines changed

README.md

+122-8
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,29 @@ The built applications will be available in `src-tauri/target/release/bundle/`.
4343

4444
```
4545
litepost/
46-
├── src/ # React frontend source
47-
│ ├── components/ # React components
48-
│ ├── hooks/ # Custom React hooks
49-
│ └── types/ # TypeScript type definitions
50-
├── src-tauri/ # Rust backend source
51-
│ ├── src/ # Rust source code
52-
│ └── capabilities/ # Tauri capability configurations
53-
└── public/ # Static assets
46+
├── src/ # React frontend source
47+
│ ├── components/ # React components
48+
│ │ └── ui/ # Reusable UI components (shadcn/ui)
49+
│ ├── hooks/ # Custom React hooks
50+
│ ├── store/ # Zustand state management
51+
│ ├── utils/ # Utility functions
52+
│ ├── types/ # TypeScript type definitions
53+
│ └── test/ # Test files
54+
├── src-tauri/ # Rust backend source
55+
│ ├── src/ # Rust source code
56+
│ └── capabilities/ # Tauri capability configurations
57+
├── public/ # Static assets
58+
├── coverage/ # Test coverage reports
59+
└── dist/ # Production build output
5460
```
5561

62+
Key directories:
63+
- `src/components/`: React components organized by feature
64+
- `src/hooks/`: Custom hooks for API requests, state management, etc.
65+
- `src/store/`: Zustand stores for collections, environments, and settings
66+
- `src/test/`: Unit tests using Vitest and React Testing Library
67+
- `src-tauri/`: Rust backend with HTTP client and file system operations
68+
5669
## Features 🚀
5770

5871
- 🎨 Modern, native UI built with React, Tailwind CSS, and Shadcn UI
@@ -99,6 +112,107 @@ litepost/
99112
- Response time validation
100113
- Test execution with results display
101114

115+
## Testing 🧪
116+
117+
The project uses Vitest for testing. Here are the available test commands:
118+
119+
```bash
120+
# Run all tests
121+
pnpm test
122+
123+
# Run tests in watch mode (useful during development)
124+
pnpm test:watch
125+
126+
# Run tests with coverage report
127+
pnpm test:coverage
128+
129+
# Run tests for a specific file
130+
pnpm test RequestUrlBar
131+
```
132+
133+
The test suite currently includes:
134+
- Unit tests for React components using React Testing Library
135+
- Component mocking (e.g., Radix UI components)
136+
- Event handling tests
137+
- State management tests
138+
- Coverage reporting with v8
139+
140+
Coverage reports can be found in:
141+
- Terminal output (text format)
142+
- `coverage/` directory (HTML and JSON formats)
143+
144+
### Planned Test Improvements 🎯
145+
146+
We plan to add:
147+
- Integration tests for API request/response flows
148+
- End-to-end tests for critical user journeys
149+
- Performance testing for large responses
150+
- Cross-platform compatibility tests
151+
152+
### Writing Tests 📝
153+
154+
Tests are located in `src/test/` and follow the naming convention `*.test.tsx`. Each test file should:
155+
- Import necessary testing utilities from `vitest` and `@testing-library/react`
156+
- Mock external dependencies when needed
157+
- Use React Testing Library's best practices for component testing
158+
159+
Example test structure:
160+
```typescript
161+
import { describe, it, expect, vi } from 'vitest'
162+
import { render, screen } from '@testing-library/react'
163+
import userEvent from '@testing-library/user-event'
164+
import { YourComponent } from '@/components/YourComponent'
165+
166+
describe('YourComponent', () => {
167+
interface SetupOptions {
168+
initialValue?: string
169+
isDisabled?: boolean
170+
}
171+
172+
const setup = (options: SetupOptions = {}) => {
173+
const user = userEvent.setup()
174+
const props = {
175+
value: options.initialValue || '',
176+
isDisabled: options.isDisabled || false,
177+
onChange: vi.fn(),
178+
onSubmit: vi.fn(),
179+
}
180+
181+
const utils = render(<YourComponent {...props} />)
182+
183+
return {
184+
user,
185+
...utils,
186+
...props,
187+
}
188+
}
189+
190+
it('renders with default props', () => {
191+
setup()
192+
expect(screen.getByRole('textbox')).toBeInTheDocument()
193+
expect(screen.getByRole('button')).toBeEnabled()
194+
})
195+
196+
it('handles user input and submission', async () => {
197+
const { user, onChange, onSubmit } = setup()
198+
199+
const input = screen.getByRole('textbox')
200+
const button = screen.getByRole('button')
201+
202+
await user.type(input, 'Hello')
203+
expect(onChange).toHaveBeenCalledWith('Hello')
204+
205+
await user.click(button)
206+
expect(onSubmit).toHaveBeenCalled()
207+
})
208+
209+
it('respects disabled state', () => {
210+
setup({ isDisabled: true })
211+
expect(screen.getByRole('textbox')).toBeDisabled()
212+
expect(screen.getByRole('button')).toBeDisabled()
213+
})
214+
})
215+
```
102216
## Contributing 🤝
103217

104218
1. Fork the repository

vitest.config.ts

+3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ export default defineConfig({
1919
'**/*.d.ts',
2020
'**/*.config.*',
2121
'**/dist/**',
22+
'src-tauri/target/**',
23+
'**/tauri-codegen-assets/**',
24+
'**/__global-api-script.js',
2225
],
2326
},
2427
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],

0 commit comments

Comments
 (0)