feat: add fire-dom-event tap action support + fix critical test performance issues #785
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Description:
Summary
Adds support for
fire-dom-eventtap action to enable compatibility with browser_mod integration and other custom event-based integrations. Includes JavaScript template rendering for dynamic entity context access. Additionally fixes critical test infrastructure issues that prevented CI from completing.Critical Performance Improvements
This PR also includes essential test infrastructure fixes:
Feature Changes
fire-dom-eventto supported action types inSupportedActionstypeIActionConfiginterface withbrowser_modfield for browser_mod specific configurationsfire-dom-eventhandler inaction.tsfollowing Home Assistant's official implementation pattern[[[ return expression ]]]syntax for dynamic entity data accessll-customDOM event dispatching (same as HA frontend core)Infrastructure Changes
Modified Files
Feature Files:
src/typings.d.ts: Addedfire-dom-eventto action types and browser_mod config fieldsrc/action.ts: Implemented fire-dom-event handler with JavaScript template engine and ll-custom event dispatchingREADME.md: Added documentation for fire-dom-event action and JavaScript templates with practical examplesInfrastructure Files:
package.json: Updated Jest dependencies (24→29), removed jest-electronjest.config.js: New configuration with optimized test environmentstest/mocks/: Added mock files for lit and custom-card-helperstsconfig.json: Added esModuleInterop and isolatedModules for better compatibility.github/workflows/: Updated to Node.js 20 and modern GitHub ActionsUsage Example
JavaScript Template Syntax
The implementation supports JavaScript templates using
[[[ return expression ]]]syntax:[[[ return entity.entity_id ]]]- Current entity ID[[[ return entity.attributes.friendly_name ]]]- Entity display name[[[ return entity.state ]]]- Current entity state[[[ return config.entity ]]]- Entity ID from configBenefits
✅ Browser_mod compatibility: Enables popups, toasts, and navigation
✅ Dynamic entity context: JavaScript templates provide access to entity data
✅ Button-card compatible: Uses familiar [[[ ]]] template syntax
✅ CI/CD Fixed: Tests complete in 90 seconds instead of timing out after 6 hours
✅ Modern infrastructure: Updated to current Node.js and Jest versions
✅ Future-proof: Follows official HA frontend implementation pattern
✅ Backward compatible: All existing configurations continue to work
✅ 100% test success: All 329 tests now pass reliably
Implementation Details
Why JavaScript Templates?
We chose JavaScript templates (
[[[ ]]]) over Jinja2 templates ({{ }}) for the following reasons:Technical Implementation
Testing
✅ All tests pass in CI (90 seconds runtime, previously 6+ hour timeout)
✅ Tested with browser_mod popups and dynamic entity data
✅ Verified JavaScript template rendering works correctly
✅ Confirmed existing actions still work (more-info, call-service, etc.)
✅ Tested error handling with invalid templates
✅ Verified proper DOM event bubbling
✅ No breaking changes to existing configurations
Performance Metrics
Related Issues
Resolves requests for browser_mod integration support and dynamic entity context access that have been mentioned in various discussions. Also resolves the long-standing CI performance issues that prevented reliable testing and releases.