# TF-02 — URL Parameter Injection

| | |
|---|---|
| **Feature** | URL parameters passed to the Pardot form via iframe `src` |
| **Test Page** | [`test-pages/01-iframe-embed.html`](../test-pages/01-iframe-embed.html) + [`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 |

---

## What We're Testing

The Pardot form relies on query string parameters to configure its behavior at runtime:
language, country routing, autoresponder content, doc download URLs, and branding.
This flow tests that all parameters are:
1. Correctly encoded in the iframe `src`
2. Read by the form's JavaScript on load
3. Changeable via the dev toolbar on Page 2 without editing HTML

---

## Parameter Reference

| Parameter | Purpose | Default (test) |
|---|---|---|
| `theme` | Form visual theme | `light` |
| `Lang_Browser` | Browser locale hint | `en-US` |
| `Form_URL` | URL of the parent page (for autoresponder back-link) | `https://go.dormakaba.com/de/test/contact-de` |
| `Language` | Form display language (controls field labels) | `DE` |
| `country` | Territory for routing logic | `US` |
| `Autoresponder_header_img` | Header image URL in confirmation email | placeholder SVG |
| `Doc_Download_Url` | Download URL shown after form submission | `…contact-de#` |
| `Doc_Img_Url` | Thumbnail image for downloaded document | installation.avif |
| `Autoresponder_body_text` | Custom body text in autoresponder | *(empty)* |
| `Doc_Name` | Display name of the document | *(empty)* |
| `Doc_History_Name` | History tracking name | *(empty)* |
| `Autoresponder_Subject` | Subject line of autoresponder email | *(empty)* |

---

## Test Steps

### 1. Verify Params in Page 1 Source
- [ ] Open `01-iframe-embed.html`
- [ ] DevTools → Elements → inspect `<iframe>` `src` attribute
- [ ] Confirm all 12 parameters above are present in the query string
- [ ] Confirm values match the URL inspector table on the page

### 2. Test Param Editing via Dev Toolbar (Page 2)
- [ ] Open `02-sfae-source.html`
- [ ] Expand the **"⚙ Dev URL Params"** panel (click the `<details>` toggle)
- [ ] All 12 inputs are visible and pre-filled from the current URL

### 3. Change `Language` parameter
- [ ] In the dev toolbar, change `Language` from `DE` to `EN`
- [ ] Click **"Apply & Reload with params"**
- [ ] Page reloads with `?Language=EN` in the URL bar
- [ ] Form labels switch to English (if the form supports language switching)

### 4. Change `country` parameter
- [ ] Set `country` to `DE` → Apply & Reload
- [ ] URL bar shows `country=DE`
- [ ] Routing logic should now match DE territory (verify via TF-07)

### 5. Change `Form_URL` parameter
- [ ] Set `Form_URL` to `https://sfae-forms.jjlo.app/test-pages/01-iframe-embed.html`
- [ ] Apply & Reload
- [ ] URL bar reflects new `Form_URL` value
- [ ] If an autoresponder fires (TF-08), the back-link in the email should reflect this URL

### 6. Empty Parameter Handling
- [ ] Clear `Autoresponder_body_text` → Apply & Reload
- [ ] Form loads without errors (empty string params are safe)
- [ ] No JS console errors related to empty params

### 7. Encoded Characters
- [ ] DevTools → Elements → check `src` after reload
- [ ] Spaces in values are encoded as `%20`
- [ ] `&` separators are correct
- [ ] No double-encoding of already-encoded values

---

## Pass Criteria

- All 12 parameters present in iframe src on Page 1
- Dev toolbar on Page 2 correctly reads, edits, and reloads with new params
- No JS errors in console during param change + reload cycle

## Edge Cases

| Case | Expected Behavior |
|---|---|
| Parameter value contains `&` | Must be encoded as `%26` in the URL |
| Parameter value is a URL with `?` | Must be fully URL-encoded |
| Empty `Language` | Form should fallback to default language |
| Unrecognized `country` value | Routing falls back to default territory |
