Files
you-music/TESTING.md
T
2025-11-02 23:11:05 +11:00

102 lines
1.7 KiB
Markdown

# Testing Guide
## Backend Tests (Python)
### Setup
```bash
cd backend
uv pip install pytest pytest-asyncio
```
### Run All Tests
```bash
pytest
```
### Run Specific Test File
```bash
pytest tests/test_artist_normalization.py
```
### Run With Verbose Output
```bash
pytest -v
```
### Run Specific Test
```bash
pytest tests/test_artist_normalization.py::TestArtistNormalization::test_multiple_artists_slash_separator
```
## Frontend Tests (TypeScript/Jest)
### Setup
```bash
cd frontend
npm install
```
### Run All Tests
```bash
npm test
```
### Run Specific Test File
```bash
npm test utils.test.ts
```
### Run Tests in Watch Mode
```bash
npm test -- --watch
```
## What's Tested
### Artist Normalization (`test_artist_normalization.py`)
- Single artist names
- Multiple artists with / separator
- Multiple artists with , separator
- Mixed separators
- Whitespace cleanup
- Unicode characters (Chinese, special chars)
- Real-world examples from database
- All artists are preserved (not just first one)
### Artist Display Formatting (`utils.test.ts`)
- Display all artists when space permits
- Smart truncation: "FirstArtist, +N"
- Single vs multiple artist handling
- Edge cases (very short maxLength)
- Real-world player scenarios
## Continuous Integration
Add to your CI/CD pipeline:
```yaml
# Backend
- cd backend && pytest
# Frontend
- cd frontend && npm test -- --ci
```
## Writing New Tests
### Backend
```python
def test_your_feature():
"""Test description"""
result = function_to_test(input)
assert result == expected_output
```
### Frontend
```typescript
test('description', () => {
const result = functionToTest(input)
expect(result).toBe(expectedOutput)
})
```