UX improvements: dark mode, tabbed editor, live preview, templates, bug fixes & tests
Summary
- Home page redesign: hero section with feature grid and CTA buttons
- Dark mode: auto (prefers-color-scheme) + manual toggle in header
- Tabbed multi-file editor: auto-detects HTML/JS/CSS, smart preview mapping
- Live preview: URL bar, reload on save, cross-origin fallback
- Templates gallery: 5 starter templates
- Keyboard shortcuts modal
- Bug fixes: tab switch data loss, preview URL persistence, cross-origin reload, file upload reset
- Cleanup: modernized URL API in crib-enable.js, improved error display with copy button, removed dead code
-
State-pattern migration: every gadget + the launcher write DOM only in
onStateChange(setState/changeState/onStateChange), perrenderjs-guidelines.md -
Unit tests (two QUnit runners):
-
test.html— editor utility functions ingadget_utils.js(21 tests, 39 assertions) -
test_gadget.html— ERP5-style direct gadget tests: real page gadgets mounted + rendered against a mocked acquired-method harness
-
Direct gadget test suite (test_gadget.html)
Expanded from 4 gadgets / 8 tests / 27 assertions to 13 gadgets / 31 tests / 115 assertions. New suites cover tools, grep, jslint, url_list, templates, snapshots, select_site, export, and cribjs_home (joining the existing app_example_list, mass_remove, add, editor).
-
Depth: pure render / safe compute branches asserted fully on DOM + state; destructive / external / multi-domain flows asserted at the "acquired method fired" level (e.g. templates install →
crib_sw_put+redirect, export zip/torrent →crib_sw_allDocs+torrent_*, snapshots remove →setSetting). Staging/merge/subdomain e2e stays with the Playwright*_checks.py. -
Harness: added
torrent_seed/torrent_getShareUrlmocks andseedSetting/seedCribEnableUrlhelpers. -
Resilience:
QUnit.config.testTimeout+ heavy sub-gadget modules (cribjs_home,editor) loaded last, so an intermittent CodeMirror mount stall fails just that test instead of silently truncating the run; the Playwright runner now waits for the final "completed in …" banner.
Test plan
-
All changes deployed to https://cribjs.nexedi.net via ZIP import -
10 Playwright smoke tests passed (home page, dark mode, navigation, editor, preview, file manager, grep, unit tests) -
QUnit utility tests ( test.html): 21/21 passed, 39/39 assertions -
QUnit gadget tests ( test_gadget.html): 31/31 passed, 115/115 assertions, 0 console errors — verified green 3× in a row viatest/playwright/cribjs_gadget_tests.py
Edited by Cédric Le Ninivin