---
name: Test Register and Activate Account
id: 1
node: 1
release: 0.3.0
---

# Test Register and Activate Account
## Summary
Verify the workflow of registering an account. This test uses global variables for environment flexibility. 
The agent must verify connectivity to the following global urls before proceeding.
- `REGISTER_URL`
- `LOGIN_URL`
- `MAILHOG_URL`
## Success Condition
- [] All connectivity checks pass (HTTP 200/3xx).
- [] All steps in the `Steps` section are completed without error.
- [] The `testuser` details are successfully saved to the `context_manager`.
## Failure Condition & Retry
- **No Retries:** If any URL is unreachable or any step fails, stop immediately and report a "Critical Environment Failure."
## Pre-flight Check
1. **Connectivity:** Navigate to `REGISTER_URL` and `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. **Data Gen:** Create a random `${test_user_name}`, `${username}`, and `${user_email}` (using `${username}@enduser1.com`). Moreover, the ${username} must be 5-32 chars, lowercase letters, digits or dot. The dot sign cannot be start or end.
2. **Register:** Navigate to `REGISTER_URL`. Fill the form:
    - Name: `${test_user_name}`
    - User Name: `${username}`
    - Password: "123456789Ab#". This value is referred as `${password}`  in the following steps.
    - Key Name: "key1". This value is referred as `${keyname}` in the following steps.
    - File Encrytion Words: "Dogs" "l@ve" "Cats". These value are referred as `${key1}`, `${key2}` and `${key3}`  in the following steps.
    - Email: `${user_email}`
3. **Save Context:** Use `context_manager.set` to save the `testuser` object:
    ```json
    {
        "username": "${username}",
        "password": "${password}",
        "keyname": "${keyname}",
        "keys": ["${key1}", "${key2}", "${key3}"],
        "email": "${user_email}",
        "channel": "a_${username}"
    }
    ```
4. **Action:** Click "Register" and wait for the "Thank you for registering!" message.
5. **Email Check:** Email MCP to find the confirmation email to `${user_email}` and click the activation link in it.
6. **Verification:** Confirm the "successfully confirmed" message appears, then close the crrent tab (the one whose url contains `/confirm-email`).
7. **Login:** Navigate to `LOGIN_URL`. Fill the username field with `${username}` and 
   the password field with `${password}`. Click the Login button and wait for the page to redirect.
   - **Success:** The page URL ends with `/` (home page)
   - **Failure:** If the text `Invalid username or password.` appears on the page, or 
     the URL still contains `/login` after 15 seconds, fail the test immediately with 
     the reason: "Login failed for user `${username}`: Invalid username or password."
8. **Initialization:** Verify `a_${username}` is in the table. Click "Initialize" 
9. **Final Verification:**  Test pass if the page is navigated to `/channel/a_${username}` with title `Channel a_${username}`. Otherwise fail the test with message "Channel intialization failed."
