# Browser Testing Framework - Rustelo

This directory contains browser testing tools for Rustelo-based applications.

## 🌐 Browser Testing Tools

### Core Scripts

- **`page-browser-tester.sh`** - Test individual pages or all pages in a browser
- **`all-pages-browser-report.sh`** - Generate comprehensive browser testing reports

### Browser Tools (`browser/`)

Advanced browser automation and logging tools for comprehensive testing.

## 🚀 Quick Start

### Basic Page Testing

```bash
# Test a single page
./scripts/testing/page-browser-tester.sh /

# Test all default pages
./scripts/testing/page-browser-tester.sh all

# Custom base URL
BASE_URL="http://localhost:8080" ./scripts/testing/page-browser-tester.sh all
```

### Custom Page Configuration

```bash
# Configure custom pages for testing
export PAGES=("/" "/blog" "/about" "/contact" "/custom-page")
./scripts/testing/page-browser-tester.sh all

# Or specify pages file location
export PAGES_MOD_FILE="crates/client/src/pages/mod.rs"
./scripts/testing/all-pages-browser-report.sh
```

### Comprehensive Reporting

```bash
# Generate full browser report
./scripts/testing/all-pages-browser-report.sh

# Generate report with custom output
./scripts/testing/all-pages-browser-report.sh custom-report.md
```

## ⚙️ Configuration

### Environment Variables

- **`BASE_URL`** - Base URL for testing (default: `http://localhost:3030`)
- **`PAGES`** - Array of pages to test (default: `"/" "/blog" "/contact" "/about"`)  
- **`PAGES_MOD_FILE`** - Path to pages module file for dynamic page detection

### Examples

```bash
# Test different environments
BASE_URL="https://staging.example.com" ./scripts/testing/page-browser-tester.sh all

# Custom pages
PAGES=("/" "/dashboard" "/settings") ./scripts/testing/page-browser-tester.sh all

# Custom pages module location
PAGES_MOD_FILE="src/routes.rs" ./scripts/testing/all-pages-browser-report.sh
```

## 🛠️ Integration with Justfile

These scripts are designed to work with the modular justfile system:

```bash
# Using aliases
just pt /blog          # Test blog page
just pr                # Generate pages report

# Using full commands  
just page-tester /about
just pages-report custom-output.md
```

## 📋 Framework Features

### For Framework Developers

- Generic page testing that works with any Rustelo application
- Configurable through environment variables
- No hardcoded application-specific pages

### For Implementation Developers

- Override default pages via environment variables
- Customize base URLs for different environments
- Generate reports specific to your application pages

## 🔧 Customization for Implementations

Implementations can create their own testing configurations:

```bash
# implementation/scripts/test-config.sh
export BASE_URL="http://localhost:3030"
export PAGES=("/" "/blog" "/prescriptions" "/services" "/contact")
export PAGES_MOD_FILE="crates/client/src/pages/mod.rs"

# Source config and run tests
source scripts/test-config.sh
../rustelo/scripts/testing/page-browser-tester.sh all
```

## 🧪 Browser Tools Directory

The `browser/` directory contains advanced browser automation tools:

- Log collection and analysis
- Browser automation scripts
- Error detection and reporting
- Performance monitoring

See `browser/README.md` for detailed documentation of these tools.

## 🤝 Contributing

When adding new testing capabilities:

1. Keep scripts generic and configurable
2. Use environment variables for customization
3. Provide sensible defaults
4. Update this documentation
5. Test with multiple implementations

This testing framework is designed to be **implementation-agnostic** while providing powerful testing capabilities for any Rustelo-based application.
