# Tests

This directory contains tests for the LED Controller project.

## Directory Structure

- `test_endpoints.py` - HTTP endpoint tests that mimic web browser requests (runs against 192.168.4.1)
- `test_ws.py` - WebSocket tests
- `test_p2p.py` - ESP-NOW P2P tests
- `models/` - Model unit tests
- `web.py` - Local development web server

## Running Tests

### Browser Tests (Real Browser Automation)

Tests the web interface in an actual browser using Selenium:

```bash
python tests/test_browser.py
```

These tests:
- Open a real Chrome browser
- Navigate to the device at 192.168.4.1
- Interact with UI elements (buttons, forms, modals)
- Test complete user workflows
- Verify visual elements and interactions

**Requirements:**
```bash
pip install selenium
# Also need ChromeDriver installed and in PATH
# Download from: https://chromedriver.chromium.org/
```

### Endpoint Tests (Browser-like HTTP)

Tests HTTP endpoints by making requests to the device at 192.168.4.1:

```bash
python tests/test_endpoints.py
```

These tests:
- Mimic web browser requests with proper headers
- Handle cookies for session management
- Test all CRUD operations (GET, POST, PUT, DELETE)
- Verify responses and status codes

**Requirements:**
```bash
pip install requests
```

### WebSocket Tests

```bash
python tests/test_ws.py
```

**Requirements:**
```bash
pip install websockets
```

### Model Tests

```bash
python tests/models/run_all.py
```

### Local Development Server

Run the local development server (port 5000):

```bash
python tests/web.py
```
