Commit 52dab5d
authored
Fix Calorie Display Bug on HRM Tile (#1629)
* test: Improve unit test coverage for critical modules
This commit adds comprehensive unit tests for `services/spotifyTokenManager.ts` and `utils/socketManager.ts`, significantly improving the test coverage and reliability of these critical modules.
The new tests cover:
- Error handling for file I/O and API calls in `spotifyTokenManager.ts`.
- All branches of the `setAccessToken` method.
- Various message handlers (`REGISTER_CLIENT`, `GET_STATE`, `SPOTIFY_COMMAND`) in `socketManager.ts`.
- Error handling for invalid messages and client lifecycle events.
Statement coverage for `spotifyTokenManager.ts` increased from 63% to 89%.
Statement coverage for `socketManager.ts` increased from 66% to 93%.
test: Address feedback on unit tests
This commit addresses the feedback from the code review:
- Replaced `require()` calls with ES6 `import` statements in `tests/unit/socketManager.test.ts` to fix linting errors.
- Improved the typing of the mocks in `tests/unit/socketManager.test.ts` to remove the need for `@ts-expect-error` comments.
- Added a new edge case test to `tests/unit/services/spotifyTokenManager.test.ts` to handle expired tokens with no refresh token.
test: Address final feedback on unit tests
This commit addresses the final feedback from the code review:
- Corrected a misleading log message in `services/spotifyTokenManager.ts` to accurately reflect the situation when a token is expired but has no refresh token.
- Updated the corresponding test in `tests/unit/services/spotifyTokenManager.test.ts` to assert the new log message.
- Ensured all linting issues are resolved.
test: Refine ws mock typing and address final feedback
This commit addresses the final feedback from the code review:
- Refined the ws mock in tests/unit/socketManager.test.ts to be more accurately typed, removing the final @ts-expect-error comment.
- Fixed all linting issues.
* feat: Apply global styling to Snackbar/Alert components
This change ensures that all MUI Snackbar and Alert components
adhere to the design system guidelines by applying styles globally
in the theme.
- Added a `MuiAlert` override in `lib/theme.ts` to set `borderRadius` to 12px.
- The `boxShadow` is inherited from the `MuiPaper` style overrides already present in the theme.
- This approach is more scalable and maintainable than creating custom styled components for each use case.
* feat: Apply global styling to Snackbar/Alert components
This change ensures that all MUI Snackbar and Alert components
adhere to the design system guidelines by applying styles globally
in the theme.
- Added a `MuiAlert` override in `lib/theme.ts` to set `borderRadius` to 12px and a compliant `boxShadow` (elevation 3).
- This approach is more scalable and maintainable than creating custom styled components for each use case, and it fully addresses the feedback from the code review.
* fix: Remove temporary test file
This commit removes the temporary Playwright test file that was
erroneously included in the previous commit, which caused the
linting step to fail.
* fix(hrm): Ensure calorie count updates on dashboard tile
- Corrected the WebSocket reducer logic to properly merge partial HRM data updates, preventing the `calories` field from being overwritten.
- Updated the `HrmConnectionPanel` to pass the `calories` data to the `HrTile` component, ensuring it is displayed on the main dashboard.
This addresses the bug where the calorie count was not updating on the HRM tile, aligning its behavior with the /client/connect page.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent 6b82e56 commit 52dab5d
3 files changed
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
133 | 133 | | |
134 | 134 | | |
135 | 135 | | |
| 136 | + | |
136 | 137 | | |
137 | 138 | | |
138 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
116 | 116 | | |
117 | 117 | | |
118 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
119 | 123 | | |
120 | 124 | | |
121 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
317 | 317 | | |
318 | 318 | | |
319 | 319 | | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
320 | 328 | | |
321 | 329 | | |
322 | 330 | | |
| |||
0 commit comments