=================================================================
   DChat Install Verification Checklist
=================================================================

Use this checklist after extracting dchat-install.zip. It proves the
server, database, dashboard, and visitor widget are working.

The examples below assume the default local runner URL:
  http://127.0.0.1:5050

If you started DChat on another port, replace 5050 with your port.

=================================================================
   1. Start The Local Demo
=================================================================

From the extracted package folder, run:

  run-local.cmd

Expected result:
  - The script finds Web\DChat.Web.dll.
  - On first run, it creates the zchatdemo database on .\SQLEXPRESS.
  - It runs install-source\ZCHAT-APP-DB.sql.
  - It runs install-source\seed-data.sql.
  - The server starts at http://127.0.0.1:5050.

If sqlcmd is missing, install SQL Server command-line tools or create
the database manually and run the two SQL scripts yourself.

=================================================================
   2. Check Health
=================================================================

Open these URLs:

  http://127.0.0.1:5050/health/live
  http://127.0.0.1:5050/health/ready

Expected result:

  /health/live returns:
    {"status":"live"}

  /health/ready returns status "ready" with database ok.

If /health/ready reports a database error, check the connection string,
SQL Server service, database name, and whether the install scripts ran.

=================================================================
   3. Sign In To The Dashboard
=================================================================

Open:

  http://127.0.0.1:5050/dashboard

Seed accounts:

  Admin:  admin  / admin123
  Agent:  agent1 / agent123

Expected result:
  - The dashboard login page loads.
  - admin / admin123 signs in.
  - The dashboard command center loads.

Important:
  These are first-run seed accounts only. Change both passwords or
  create real accounts before shared testing or production use.

  Upgrading from an earlier build signs everyone out once: sessions are
  now bound to the account password, and tokens issued before this build
  are refused. Expected; sign in again.

=================================================================
   4. Check The Visitor Widget
=================================================================

Open:

  http://127.0.0.1:5050/widget-test.html

Expected result:
  - The widget test page loads.
  - API Server shows healthy.
  - The chat bubble appears in the bottom-right corner.

Also check the widget bundle directly:

  http://127.0.0.1:5050/widget/dchat.iife.js

Expected result:
  - The JavaScript file loads with HTTP 200.

=================================================================
   5. Check Public Widget APIs
=================================================================

Open:

  http://127.0.0.1:5050/api/v1/widget/status
  http://127.0.0.1:5050/api/v1/widget/triggers

Expected result:
  - Both return HTTP 200.
  - status returns online/offline information.
  - triggers returns an array, even if empty.

To test offline message storage, submit a message from the widget UI
while no agents are online. Then check Dashboard > Missed Chats.

=================================================================
   6. Production Readiness Checks
=================================================================

Before production:

  - Replace localhost URLs with your real HTTPS domain.
  - No licence file is needed for live chat (Community). If you bought
    Premium or Enterprise, place your dchat.lic in the Web folder.
  - Update Web\appsettings.json or environment variables with your
    production SQL Server connection string.
  - Change or remove seed passwords.
  - Put the server behind HTTPS using IIS, Nginx, or another reverse
    proxy.
  - Back up the SQL database, Web\App_Data (per-install secrets), and
    Web\dchat.lic if you have one. Never publish App_Data.
  - Confirm the widget script uses your public server URL:

      <script src="https://YOUR-DOMAIN/widget/dchat.iife.js"
              data-server-url="https://YOUR-DOMAIN"
              data-site-id="default"></script>

=================================================================
   Troubleshooting
=================================================================

Cannot connect to dashboard:
  - Confirm the server window is still running.
  - Confirm the port in the URL matches the run-local output.

License error (Premium/Enterprise only):
  - Confirm Web\dchat.lic is the file from the client center.
  - A replaced licence is picked up within about 10 seconds; no restart
    is needed. Without a licence DChat runs as the free Community edition.

Database error:
  - Confirm SQL Server is running.
  - Confirm the connection string points to the correct database.
  - Confirm ZCHAT-APP-DB.sql and seed-data.sql completed.

Login does not work:
  - Confirm seed-data.sql ran.
  - Confirm you are using admin / admin123 only for a fresh demo DB.
  - If passwords were changed, use the updated credentials.

Widget does not appear:
  - Confirm /widget/dchat.iife.js returns HTTP 200.
  - Confirm data-server-url matches the server URL.
  - Check the browser console for mixed-content errors if your page is
    HTTPS but the widget URL is HTTP.
