|
| 1 | +--- |
| 2 | +name: webchat-html-tests |
| 3 | +description: 'Run Bot Framework Web Chat HTML tests in Docker/Selenium Grid. Use when: running __tests__/html2, debugging failing HTML tests, updating snapshots, checking grid health, or cleaning leaked Selenium sessions.' |
| 4 | +argument-hint: 'Optional HTML test regex' |
| 5 | +--- |
| 6 | + |
| 7 | +# Web Chat HTML Tests |
| 8 | + |
| 9 | +Run the HTML test harness, keep Selenium Grid healthy, and debug failures without keeping all of the operational detail in the skill body. |
| 10 | + |
| 11 | +## When to Use |
| 12 | + |
| 13 | +- Running `__tests__/html2` for a branch or PR |
| 14 | +- Debugging a failing HTML or snapshot test |
| 15 | +- Updating snapshots after an intentional visual change |
| 16 | +- Checking whether Selenium Grid is ready or leaking sessions |
| 17 | + |
| 18 | +## Procedure |
| 19 | + |
| 20 | +### 1. Start Selenium Grid |
| 21 | + |
| 22 | +Use the bundled script instead of pasting long Docker commands. |
| 23 | + |
| 24 | +For a focused test run, keep the default scale of 2 Chrome nodes: |
| 25 | + |
| 26 | +```sh |
| 27 | +./.github/skills/webchat-html-tests/scripts/start-grid.sh |
| 28 | +``` |
| 29 | + |
| 30 | +For a full run, match Jest's 4 workers: |
| 31 | + |
| 32 | +```sh |
| 33 | +CHROME_SCALE=4 ./.github/skills/webchat-html-tests/scripts/start-grid.sh |
| 34 | +``` |
| 35 | + |
| 36 | +### 2. Wait for Grid Readiness |
| 37 | + |
| 38 | +```sh |
| 39 | +python3 ./.github/skills/webchat-html-tests/scripts/wait-for-grid.py |
| 40 | +``` |
| 41 | + |
| 42 | +Stop if the script times out or if the node summary does not show ready nodes. |
| 43 | + |
| 44 | +### 3. Run Tests |
| 45 | + |
| 46 | +Run the full suite: |
| 47 | + |
| 48 | +```sh |
| 49 | +./.github/skills/webchat-html-tests/scripts/run-html-tests.sh |
| 50 | +``` |
| 51 | + |
| 52 | +Run a focused HTML test with a regex anchored to the exact file: |
| 53 | + |
| 54 | +```sh |
| 55 | +./.github/skills/webchat-html-tests/scripts/run-html-tests.sh "__tests__/html2/activity/message-status\.html$" |
| 56 | +``` |
| 57 | + |
| 58 | +Update snapshots for an expected visual change: |
| 59 | + |
| 60 | +```sh |
| 61 | +./.github/skills/webchat-html-tests/scripts/run-html-tests.sh --update "__tests__/html2/activity/message-status\.html$" |
| 62 | +``` |
| 63 | + |
| 64 | +### 4. Clean Grid Sessions After Every Run |
| 65 | + |
| 66 | +```sh |
| 67 | +python3 ./.github/skills/webchat-html-tests/scripts/cleanup-grid-sessions.py |
| 68 | +``` |
| 69 | + |
| 70 | +If leaked sessions remain, clean them before the next Jest run or the grid can stall. |
| 71 | + |
| 72 | +### 5. Recover Common Infra Problems |
| 73 | + |
| 74 | +If dist files return 404s after a local build, restart `webchat2`: |
| 75 | + |
| 76 | +```sh |
| 77 | +docker compose -f docker-compose-wsl2.yml restart webchat2 |
| 78 | +``` |
| 79 | + |
| 80 | +If a failure is not obvious, load the reference docs before changing code: |
| 81 | + |
| 82 | +- [Architecture and test layout](./references/architecture.md) |
| 83 | +- [Failure modes and snapshot workflow](./references/failure-modes.md) |
| 84 | + |
| 85 | +### 6. Tear Down |
| 86 | + |
| 87 | +```sh |
| 88 | +docker compose -f docker-compose-wsl2.yml down |
| 89 | +``` |
| 90 | + |
| 91 | +## Checklist |
| 92 | + |
| 93 | +- [ ] Grid is ready before running Jest |
| 94 | +- [ ] Focused tests use an anchored regex when targeting one HTML file |
| 95 | +- [ ] Sessions are cleaned after every run |
| 96 | +- [ ] Snapshot updates are rerun without `--update` |
| 97 | +- [ ] `npm run precommit` passes before opening the PR |
0 commit comments