---
name: test-web-config
description: Configure test-web targets from external config file
argument-hint: "[path/to/config.json]"
allowed-tools: Read, Write, AskUserQuestion, Glob
model: haiku
---

# Test Web Configuration

Updates web test configuration from external file.

## Usage

```bash
/utils test-web-config                     # Ask for file interactively
/utils test-web-config path/to/config.json # Load file directly
```

## Workflow

### 1. Get Source File

**If argument provided**: Use given path

**Otherwise**: Ask user

```yaml
questions:
  - header: "Config file"
    question: "Which configuration file do you want to load?"
    options:
      - label: "Search in project"
        description: "Glob to find *test-web*.json files"
      - label: "Enter path"
        description: "Manually specify file path"
    multiSelect: false
```

### 2. Validate File

1. Check file exists
2. Read JSON content
3. Validate structure (targets, settings)

**Expected structure**:

```json
{
  "targets": [
    {
      "name": "string (required)",
      "url": "string (required for fetch)",
      "query": "string (required for search)",
      "type": "fetch|search (required)",
      "expects": {
        "status": "number (optional)",
        "contains": ["strings"] "(optional)",
        "hasResults": "boolean (optional)"
      }
    }
  ],
  "chrome": {
    "enabled": "boolean",
    "targets": [...]
  },
  "settings": {
    "timeout": "number",
    "retries": "number",
    "reportPath": "string"
  }
}
```

### 3. Merge or Replace

```yaml
questions:
  - header: "Mode"
    question: "How to apply new configuration?"
    options:
      - label: "Replace"
        description: "Completely replace existing config"
      - label: "Merge (add)"
        description: "Add new targets to existing"
    multiSelect: false
```

### 4. Apply

1. Read existing `.claude/test-web/config.json`
2. Apply chosen mode (replace or merge)
3. Write result

### 5. Confirm

```
CONFIG UPDATED
------------------------------------
Source:  {source_file_path}
Mode:    {replace|merge}
Targets: {total_count}
------------------------------------

Test now:
/utils test-web --quick
```

## Example Source Files

### Minimal

```json
{
  "targets": [
    {
      "name": "My site",
      "url": "https://example.com",
      "type": "fetch",
      "expects": { "status": 200 }
    }
  ]
}
```

### Complete

```json
{
  "targets": [
    {
      "name": "API Health",
      "url": "https://api.example.com/health",
      "type": "fetch",
      "expects": {
        "status": 200,
        "contains": ["healthy", "ok"]
      }
    },
    {
      "name": "SEO Check",
      "query": "site:example.com",
      "type": "search",
      "expects": { "hasResults": true }
    }
  ],
  "settings": {
    "timeout": 60000,
    "retries": 3
  }
}
```
