|
| 1 | +# End-to-End Testing Setup - Implementation Complete ✅ |
| 2 | + |
| 3 | +This document summarizes the end-to-end testing implementation for WLED. |
| 4 | + |
| 5 | +## What Was Implemented |
| 6 | + |
| 7 | +A complete CI/CD workflow that: |
| 8 | +1. Builds actual WLED firmware for ESP32 |
| 9 | +2. Runs the firmware in a Wokwi ESP32 simulator |
| 10 | +3. Tests the web UI using Playwright browser automation |
| 11 | +4. Validates that all pages load without JavaScript errors |
| 12 | +5. Generates detailed test reports and debugging artifacts |
| 13 | + |
| 14 | +## Files Created/Modified |
| 15 | + |
| 16 | +### GitHub Actions Workflow |
| 17 | +- `.github/workflows/e2e-test.yml` - Main CI workflow (223 lines) |
| 18 | + |
| 19 | +### Playwright Configuration |
| 20 | +- `playwright.config.js` - Playwright test configuration |
| 21 | +- `package.json` - Added Playwright dependencies and test scripts |
| 22 | + |
| 23 | +### Test Files |
| 24 | +- `tests/e2e/ui-pages.spec.js` - Tests for 12+ web UI pages (169 lines) |
| 25 | + |
| 26 | +### Documentation |
| 27 | +- `docs/E2E_TESTING.md` - Main E2E testing documentation |
| 28 | +- `docs/E2E_ALTERNATIVES.md` - Alternative approaches (ESP32 QEMU, Renode, etc.) |
| 29 | +- `tests/e2e/README.md` - Developer guide for E2E tests |
| 30 | + |
| 31 | +### Configuration Updates |
| 32 | +- `.gitignore` - Added Playwright and Wokwi artifacts |
| 33 | + |
| 34 | +## Test Coverage |
| 35 | + |
| 36 | +The automated tests validate: |
| 37 | + |
| 38 | +✅ **Main Pages:** |
| 39 | +- Index/home page |
| 40 | +- Settings page |
| 41 | + |
| 42 | +✅ **Settings Sub-pages:** |
| 43 | +- WiFi settings (`settings_wifi.htm`) |
| 44 | +- LED settings (`settings_leds.htm`) |
| 45 | +- UI settings (`settings_ui.htm`) |
| 46 | +- Sync settings (`settings_sync.htm`) |
| 47 | +- Time settings (`settings_time.htm`) |
| 48 | +- Security settings (`settings_sec.htm`) |
| 49 | +- DMX settings (`settings_dmx.htm`) |
| 50 | +- Usermod settings (`settings_um.htm`) |
| 51 | +- 2D settings (`settings_2D.htm`) |
| 52 | + |
| 53 | +✅ **Other Pages:** |
| 54 | +- Update page (`update.htm`) |
| 55 | + |
| 56 | +✅ **Validation:** |
| 57 | +- All pages load without errors |
| 58 | +- No JavaScript console errors |
| 59 | +- Basic navigation works |
| 60 | + |
| 61 | +## How It Works |
| 62 | + |
| 63 | +``` |
| 64 | +Build Web UI → Build Firmware → Start Simulator → Run Tests → Report Results |
| 65 | + (npm) (PlatformIO) (Wokwi) (Playwright) (Artifacts) |
| 66 | +``` |
| 67 | + |
| 68 | +1. **Build Phase**: Compiles web UI and ESP32 firmware |
| 69 | +2. **Simulation Phase**: Starts Wokwi with firmware, forwards port 80→8180 |
| 70 | +3. **Test Phase**: Playwright opens Chromium and tests each page |
| 71 | +4. **Report Phase**: Generates HTML reports, collects logs, uploads artifacts |
| 72 | + |
| 73 | +## Required Setup (Action Needed! 🚨) |
| 74 | + |
| 75 | +### For Repository Administrators |
| 76 | + |
| 77 | +To enable this workflow, you need to add a GitHub Secret: |
| 78 | + |
| 79 | +1. Go to https://wokwi.com/dashboard/ci |
| 80 | +2. Sign up/login and get a Wokwi CLI license token |
| 81 | +3. In this repository, go to: **Settings** → **Secrets and variables** → **Actions** |
| 82 | +4. Click **New repository secret** |
| 83 | +5. Name: `WOKWI_CLI_TOKEN` |
| 84 | +6. Value: Your Wokwi CLI token |
| 85 | +7. Click **Add secret** |
| 86 | + |
| 87 | +### Pricing Note |
| 88 | + |
| 89 | +Wokwi CLI for CI: |
| 90 | +- Free tier: Limited usage (check Wokwi website) |
| 91 | +- Paid plans: Available for commercial use |
| 92 | +- Alternative: See `docs/E2E_ALTERNATIVES.md` for open-source options |
| 93 | + |
| 94 | +## Running the Workflow |
| 95 | + |
| 96 | +### Automatic Triggers |
| 97 | + |
| 98 | +The workflow runs automatically on: |
| 99 | +- Pushes to `mdev` branch |
| 100 | +- Pushes to `main` branch |
| 101 | +- Pull requests to `mdev` or `main` |
| 102 | + |
| 103 | +### Manual Trigger |
| 104 | + |
| 105 | +1. Go to **Actions** tab |
| 106 | +2. Select "End-to-End Testing with ESP32 Emulation" |
| 107 | +3. Click **Run workflow** |
| 108 | +4. Select branch and click **Run workflow** |
| 109 | + |
| 110 | +## Viewing Test Results |
| 111 | + |
| 112 | +After a workflow run: |
| 113 | + |
| 114 | +1. Go to **Actions** tab |
| 115 | +2. Click on the workflow run |
| 116 | +3. View the job logs for debugging |
| 117 | +4. Download artifacts: |
| 118 | + - **playwright-report**: HTML test report with screenshots |
| 119 | + - **wokwi-logs**: Simulator console output |
| 120 | + |
| 121 | +## Troubleshooting |
| 122 | + |
| 123 | +### Workflow doesn't start |
| 124 | +- Ensure workflow file is on `mdev` or `main` branch |
| 125 | +- Check GitHub Actions are enabled for the repository |
| 126 | + |
| 127 | +### "WOKWI_CLI_TOKEN" not found |
| 128 | +- Add the secret as described above |
| 129 | +- Verify the secret name is exactly `WOKWI_CLI_TOKEN` |
| 130 | + |
| 131 | +### Simulator doesn't start |
| 132 | +- Check firmware built successfully |
| 133 | +- Look at wokwi-logs artifact for error messages |
| 134 | +- May need to increase timeout in workflow |
| 135 | + |
| 136 | +### Tests fail |
| 137 | +- Download playwright-report artifact |
| 138 | +- Open `index.html` in a browser |
| 139 | +- Review screenshots and error messages |
| 140 | +- Check for actual bugs in web UI or test issues |
| 141 | + |
| 142 | +## Extending the Tests |
| 143 | + |
| 144 | +To add more tests: |
| 145 | + |
| 146 | +1. Edit `tests/e2e/ui-pages.spec.js` |
| 147 | +2. Or create new `*.spec.js` files in `tests/e2e/` |
| 148 | +3. Follow the existing pattern: |
| 149 | + ```javascript |
| 150 | + test('my test', async ({ page }) => { |
| 151 | + await page.goto('/my-page.htm'); |
| 152 | + await page.waitForLoadState('networkidle'); |
| 153 | + await expect(page.locator('body')).toBeVisible(); |
| 154 | + }); |
| 155 | + ``` |
| 156 | + |
| 157 | +## Future Enhancements |
| 158 | + |
| 159 | +Possible additions: |
| 160 | +- [ ] API endpoint testing |
| 161 | +- [ ] WebSocket communication tests |
| 162 | +- [ ] Form submission tests |
| 163 | +- [ ] Effect activation tests |
| 164 | +- [ ] Performance benchmarks |
| 165 | +- [ ] Multi-browser testing (Firefox, Safari) |
| 166 | +- [ ] Test with ethernet build instead of WiFi |
| 167 | +- [ ] Test different ESP32 variants (S2, S3, C3) |
| 168 | + |
| 169 | +## Alternative Approaches |
| 170 | + |
| 171 | +If Wokwi doesn't work for your use case, see: |
| 172 | +- `docs/E2E_ALTERNATIVES.md` for other options: |
| 173 | + - ESP32 QEMU (open source) |
| 174 | + - Renode (open source) |
| 175 | + - Mock HTTP server (simple, but limited) |
| 176 | + |
| 177 | +## Questions? |
| 178 | + |
| 179 | +- **General E2E testing**: See `docs/E2E_TESTING.md` |
| 180 | +- **Alternative approaches**: See `docs/E2E_ALTERNATIVES.md` |
| 181 | +- **Developer guide**: See `tests/e2e/README.md` |
| 182 | +- **Playwright docs**: https://playwright.dev/ |
| 183 | +- **Wokwi docs**: https://docs.wokwi.com/ |
| 184 | + |
| 185 | +## Summary |
| 186 | + |
| 187 | +✅ **Complete workflow implemented** |
| 188 | +✅ **12+ pages tested automatically** |
| 189 | +✅ **Comprehensive documentation** |
| 190 | +✅ **Ready to run** (after adding WOKWI_CLI_TOKEN) |
| 191 | + |
| 192 | +**Next Step**: Add `WOKWI_CLI_TOKEN` secret and trigger a test run! |
0 commit comments