Commit 7b5fcdb
fix(web): use configured currency minor unit in Rates chart legend (#4307)
* fix(web): use configured currency minor unit in Rates chart legend
The Rates chart's "Hourly"/"Today" series legends were hardcoded to
"p/kWh" (pence) regardless of the configured currency_symbols, so
non-GBP users (e.g. NZD, configured as "$c") saw "p/kWh" in the chart
legend even though the surrounding chart title/axis already correctly
used self.currency_symbols[1]. Fixes #4153.
Added a test verifying the series-name formatting follows
currency_symbols for £p/$c/€c - get_chart() itself requires a fully
computed plan before reaching this branch, so the test mirrors the
formatting logic directly rather than standing up that heavier
machinery (matching this file's existing "Loading..." early-return
gate and the lack of any content assertions in test_web_if.py's
integration tests).
🤖 Implemented with Claude Code, disclosed per repo convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(web): address Copilot review feedback on the Rates chart currency test
Two issues flagged on PR #4288:
- The test mutated my_predbat.currency_symbols without restoring it,
leaking state into later tests in the same suite process (the shared
my_predbat fixture is reused across all tests).
- The test never actually called WebInterface.get_chart()/web.py - it only
re-tested the same inline string-formatting logic, so it would still
pass even if web.py regressed back to a hardcoded "p/kWh".
Now builds a minimal WebInterface (bypassing ComponentBase.__init__, which
would stand up the real aiohttp app) and calls the real get_chart("Rates"),
stubbing get_history_wrapper() directly to avoid reproducing realistic HA
history formatting for data not under test. Verified this actually catches
a regression: temporarily reintroducing the hardcoded "p/kWh" strings in
web.py makes the test fail as expected. currency_symbols/dashboard_values
are now saved and restored via try/finally.
🤖 Implemented with Claude Code, disclosed per repo convention.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
* test(web): use my_predbat.prefix instead of hardcoded entity IDs
Copilot review on #4307: the test stubbed dashboard_values using
hardcoded "predbat.*" entity IDs, so it would silently pass if the
test harness prefix ever differed from get_chart()'s own self.prefix
lookup. Build the keys from my_predbat.prefix instead, matching how
get_chart() actually resolves them.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Trefor Southwell <48591903+springfall2008@users.noreply.github.com>1 parent b6d3734 commit 7b5fcdb
3 files changed
Lines changed: 94 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
69 | 70 | | |
70 | 71 | | |
71 | 72 | | |
| |||
283 | 284 | | |
284 | 285 | | |
285 | 286 | | |
| 287 | + | |
286 | 288 | | |
287 | 289 | | |
288 | 290 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2964 | 2964 | | |
2965 | 2965 | | |
2966 | 2966 | | |
2967 | | - | |
2968 | | - | |
| 2967 | + | |
| 2968 | + | |
2969 | 2969 | | |
2970 | 2970 | | |
2971 | 2971 | | |
| |||
0 commit comments