# Test Option A – Do This Now

## 1. Make sure backend is running

- If port 5000 is free: run in a terminal  
  `cd backend/unified_server` then `npm run dev`
- If you see "address already in use :::5000", another process is using 5000 (e.g. backend already running). You can test as-is.

## 2. Start the frontend

In another terminal:
```bash
cd frontend
npm run dev
```
Open the URL shown (e.g. http://localhost:5173).

## 3. Get your token and IDs from the browser

1. Log in with a user that **has a business**.
2. Press **F12** → open **Application** (Chrome) or **Storage** (Firefox).
3. Under **Local Storage** → select your site (e.g. http://localhost:5173).
4. Copy these values (right-click → Copy value):
   - **token** (or **access_token**) – long JWT string
   - **user_id** – your user UUID  
     (if missing, copy from **user** → paste in Notepad and get the `"id"` value)
   - **business_id** – your business UUID

## 4. Run the Phase 1 API test

**You must run this from the backend folder** (not from `C:\Users\smart` or the repo root). In a terminal:

```bash
cd D:\Dev\Chat-Automation\backend\unified_server
node scripts/test_integration_api.js "PASTE_TOKEN_HERE" "PASTE_USER_ID_HERE" "PASTE_BUSINESS_ID_HERE"
```

(On PowerShell you can use the same `cd` path. Replace the three placeholders with your copied values; keep the quotes.)

**Expected:** You see "PASS" for GET status and POST connect, then "Phase 1 API test completed."

If you see "Request failed" or "ECONNREFUSED", the backend is not running or not on port 5000.

## 5. Test Phase 2 in the app (Connect WhatsApp)

1. In the app, go to **Settings** → **Channels** tab.
2. You should see "Not connected" or "Connected".
3. Enter a **Phone Number ID** and **Access Token** (from Meta Developer Dashboard → WhatsApp → API Setup, or use test values like `123456789012345` and `test_token`).
4. Click **Connect WhatsApp**.
5. You should get a success message and status "Connected".

## 6. Test Phase 3 (no-business user)

1. Log out or use a different user that has **no business**.
2. Open **Inbox** → you should see "Create a business to use the Inbox" and links.
3. Open **Contacts** → same style "Create a business" message.
4. Open **Dashboard** → banner at top with "Create business" button.
5. Create a business (e.g. via "Create business" or Settings → Workspace).
6. Inbox and Contacts should work; banner should disappear.

---

**One-liner (run from anywhere; replace the three values):**
```bash
cd D:\Dev\Chat-Automation\backend\unified_server
node scripts/test_integration_api.js "YOUR_TOKEN" "YOUR_USER_ID" "YOUR_BUSINESS_ID"
```
