---
name: Test New Subscription Route
id: 2
node: 2
required: 1
release: 0.3.0
---

# Test New Subscription Route
## Summary
Test the workflow of creating a subsciption route and verify only emails from whitelisted senders are allowed.
The agent must verify connectivity to the following global urls before proceeding.
- `LOGIN_URL`
- `MAILHOG_URL`
## Success Condition
- [] All connectivity checks pass (HTTP 200/3xx).
- [] All steps in the `Steps` section are completed without error.
## Failure Condition & Retry
- **No Retries:** If any URL is unreachable or any step fails, stop immediately and report a "Critical Environment Failure."
- **TimeOut:** Unless specified individually, each test step times out in 30 seconds. Test should fail immediately any timeout limit reaches.
## Pre-flight Check
1. **Connectivity:** Navigate to `LOGIN_URL`. Confirm reachability from the returned page URL and title only — do NOT call `take_verification_snapshot` for connectivity checks.
2. **Validation:** If any page fails to load or returns a server error (5xx), fail the test immediately with the reason: "Target environment at ${URL} is offline."

## Steps
1. **Get Test User:** Verify that `context.testuser` exists in the context manager. If it is missing, fail the test immediately with the reason: "Node 1 data is required."
2. **Login:** Navigate to `LOGIN_URL` and perform login using the retrieved credentials.
3. **Open Channel Config Page:** Click `Manage` button at the row of `a_${context.testuser.username}` to open `Channel Config` page
4. **Add Route:** Click the `Add Route` button to open the `Add Route` dialog. Fill `Route ID` with `news` and `Description` with `Newsletter`. Click `Save`. Do NOT wait for dialog close confirmation — proceed directly to Step 5 which will verify the route appears in the table.
5. **Verify Route:** Verify route `news` is displayed as a row of the table with type `Subscription` and status `Enabled`. If the row is missing or values are incorrect, fail the test immediately with the reason: "Route `news` not found or has unexpected type/status."
6. **Send First Email:** Use Email MCP to send the following email payload
    ```json
    {
        "from": "noreply@bounce.newsa.com",
        "to": ["a_${context.testuser.username}_news@duotail.com"],
        "subject": "News A Daily Brief",
        "content": "There is the breaking news today"
    }
    ```
7. **Verify Email Received:** Use Email MCP to verify an email with title `News A Daily Brief` is received from `1_a_${context.testuser.username}_news@duotail.com`.
8. **Return to Channel Page:** Switch to `${LOGIN_URL}/channel/a_${context.testuser.username}` and refresh it. If redirected to `/login`, re-login using `${context.testuser.username}` and `${context.testuser.password}` before continuing.
9. **Open Edit Route Window:** Click the `Update` button on the `news` row to open the `Edit Route` dialog. Click the `Permissions` tab inside the dialog and wait for the tab content to load.
10. **Verify Domain Permissions:** Verify both `bounce.newsa.com` and `newsa.com` appear as green pills. If either is missing, fail the test immediately with the reason: "Domain permission missing: `${domain}` not found in Permissions tab of route `news`". After verification, dismiss the `Edit Route` dialog by pressing `Escape` before proceeding to the next step.
11. **Send Email To Be Blocked:** Use Email MCP to send the following email payload
    ```json
    {
        "from": "noreply@daily.newsb.com",
        "to": ["a_${context.testuser.username}_news@duotail.com"],
        "subject": "News B Daily Brief",
        "content": "There are news you may interested in"
    }
    ```
12. **Verify Email Blocked:** Navigate to the `History` page by clicking the `History` menu on the top bar. Look for a row with `FROM` set to `noreply@daily.newsb.com` and `STATUS` set to `Blocked`. 
    - **If found:** Test passes.
    - **If not found:** Refresh the page up to 3 times with 5 seconds between each refresh.
        - **If the row found during the refresh:** Test passes
        - **If after 3 refreshes the row exists but STATUS is not `Blocked`:** Fail the test immediately with the reason: "Email from `noreply@daily.newsb.com` was received but not blocked."
        - **If after 3 refreshes the row is still missing:** Fail the test immediately with the reason: "Email from `noreply@daily.newsb.com` not found in History after 3 retries."