Extract the automation editor header title into a pure module#970
Conversation
There was a problem hiding this comment.
Pull request overview
Refactors the automation editor’s header-title derivation into a DOM/API-free utility so it can be unit-tested without mounting the large automation-editor Lit component.
Changes:
- Added
automationHeaderTitle(location, trigger, localize)pure helper insrc/util/automation-header-title.ts. - Updated
ESPHomeAutomationEditor._headerTitle()to delegate to the new helper. - Added unit tests covering the helper’s location/trigger branching.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| test/util/automation-header-title.test.ts | Adds branch-coverage unit tests for the extracted title derivation helper. |
| src/util/automation-header-title.ts | Introduces a pure utility for deriving the automation editor header title from inputs. |
| src/components/device/automation-editor/automation-editor.ts | Replaces inline branching logic with a one-line call to the new util. |
PR Review — Extract the automation editor header title into a pure moduleClean, behavior-preserving extraction. Merge-ready. The extracted Strengths:
Automated review by Kōan (Claude) |
Simple rebaseBranch StatsActions performed
CI statusCI will be checked asynchronously. Automated by Kōan |
What
Extract the automation editor's header-title derivation into a pure
src/util/automation-header-title.tsmodule.Why
_headerTitleinautomation-editor.tswas inline branching logic overlocation+trigger+_localize— pure over plain inputs, but untestable without mounting the 1063-line component. It already composed a sibling util (actionFieldLabel), so the rule was half-split; this finishes the move. Same shape as the recently mergedaction-field-label, shortcut-target (#960), and config-entry-ordering (#938) extractions.How
automationHeaderTitle(location, trigger, localize)— DOM/API-free,localizeinjected as a callback (mirrorsactionFieldLabel).actionFieldLabelimport is replaced by the new util.Testing
test/util/automation-header-title.test.tscovers every location branch (interval, device_on/component_on with and without a resolved trigger, component_action, script, null).npm run lint(tsc) clean,prettier --checkclean, fullvitest rungreen via the pre-push hook.Types of changes
refactorNo companion backend PR — frontend-only refactor.
Quality Report
Changes: 3 files changed, 100 insertions(+), 12 deletions(-)
Code scan: clean
Tests: failed (timeout (120s))
Branch hygiene: clean
Generated by Kōan