# TF-07 — Support Routing (supportData)

| | |
|---|---|
| **Feature** | Dynamic support contact routing based on country × product category selection |
| **Test Page** | [`test-pages/02-sfae-source.html`](../test-pages/02-sfae-source.html) |
| **Live URL** | https://sfae-forms.jjlo.app/test-pages/02-sfae-source.html |
| **Status** | ✅ Ready |
| **Last Verified** | 2026-05-24 |
| **Code Location** | `02-sfae-source.html` L1235–L1870 |

---

## What We're Testing

The form includes a large `supportData` JSON array (L1235–L1857) that maps:
- **Country** + **Product Category** → Support phone number, email, team name

When the prospect selects their country and product interest, the form dynamically shows the correct regional support contact.
This routing must show the right contact and fail gracefully when no match is found.

---

## supportData Structure (abbreviated)

```javascript
var supportData = [{
  country: "DE",
  category: "Access Management",
  phone: "+49 6002 702-0",
  email: "service.de@dormakaba.com",
  team: "dormakaba DE Service"
}, ...];
```

Match logic (L1858–L1870):
1. Exact match on `country` + `category`
2. Fallback: match on `country` only
3. Fallback: first entry in array (default)

---

## Test Steps

### 1. Inspect the Data
- [ ] Open `02-sfae-source.html`
- [ ] DevTools console: `supportData.length` → should return a number > 1
- [ ] `supportData[0]` → inspect structure, confirm `country`, `category`, `phone` or `email` fields exist

### 2. Select Country
- [ ] Find the country dropdown in the form
- [ ] Select **Germany (DE)**
- [ ] The form should dynamically update the displayed support contact

### 3. Exact Match (Country + Category)
- [ ] Select country = **DE** and product category = **Access Management** (or whatever the first category is)
- [ ] Verify: correct DE phone/email for Access Management appears
- [ ] Select a different category for same country
- [ ] Verify: support contact updates to match new category

### 4. Country-Only Fallback
- [ ] Select a country that has entries but with a category that doesn't match exactly
- [ ] Verify: falls back to country-level default contact (not a random entry)

### 5. No Match Fallback
- [ ] In console: `supportData.find(d => d.country === "ZZ")` → `undefined`
- [ ] Select a country not in supportData (if UI allows)
- [ ] Verify: form shows default/first entry, no JS error thrown

### 6. Phone Number Format
- [ ] For DE matches: phone starts with `+49`
- [ ] No broken/null phone values displayed
- [ ] Phone is displayed in a clickable `tel:` link format (if applicable)

### 7. Console Errors
- [ ] No `Cannot read property` errors when iterating supportData
- [ ] No `undefined` display values shown to the prospect

---

## Pass Criteria

Correct support contact shown for each country/category combination. Fallback works when no exact match. No JS errors during selection changes.

## Adding New Routes

When a new country or product category is added to the dormakaba portfolio:
1. Add entry to `supportData` array in the form's custom code section
2. Deploy updated form in SFAE
3. Re-run this test flow for the new entry
4. Update this file with the new test case

## Related Docs

- [`lead-routing-conversion.md`](../PDD/lead-routing-conversion.md) — Territory routing rules and MQL thresholds
- [`forms-inventory.md`](../forms-inventory.md) — Country-specific form variants
