Skip to content

fix(home/kpi): format Current Coverage / Target with one decimal - #967

Merged
cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/dashboard-coverage-formatting
Jun 5, 2026
Merged

cristim merged 2 commits into
feat/multicloud-web-frontendfrom
fix/dashboard-coverage-formatting

Conversation

@cristim

@cristim cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member

Summary

The "Current Coverage" KPI tile on the Home page was rendering the raw float when the backend returned a fractional value:

Current Coverage: 0.14648736342042862%
Target: 80%

…because frontend/src/dashboard.ts:271-272 interpolated the number with no formatting:

const coverageValue = nothingTracked ? '—' : `${data.current_coverage || 0}%`;
const coverageDetail = nothingTracked ? 'No services tracked' : `Target: ${data.target_coverage || 80}%`;

Fix

Apply .toFixed(1) to both current_coverage and target_coverage, matching the convention already used by inventory.ts:357,407 and recommendations.ts:2714.

Result: the tile now reads Current Coverage: 0.1% / Target: 80.0%.

Test plan

  • tsc --noEmit clean
  • New regression test in dashboard.test.ts: a synthetic summary with current_coverage = 0.14648736342042862 renders 0.1%, never the raw float
  • Existing tests with integer current_coverage (70, 60, 50, 0) keep passing — .toFixed(1) on those produces 70.0% etc., backward-compatible since no test asserts on the exact rendered string

@cristim cristim added priority/p3 Polish / idea / may never ship severity/low Minor harm urgency/this-sprint Within the current sprint impact/all-users Affects every user bug Something isn't working triaged Item has been triaged labels Jun 5, 2026
@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@cristim, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 27 minutes and 38 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b11f4bcf-0855-443c-8398-fad3ef724bd1

📥 Commits

Reviewing files that changed from the base of the PR and between 20ce559 and 92a1f28.

📒 Files selected for processing (3)
  • frontend/src/__tests__/dashboard.test.ts
  • frontend/src/dashboard.ts
  • internal/api/handler_purchases_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/dashboard-coverage-formatting

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim force-pushed the fix/dashboard-coverage-formatting branch from 633bf35 to 993afcc Compare June 5, 2026 10:26
@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

cristim added 2 commits June 5, 2026 12:38
When the backend returned a fractional `current_coverage` value, the
dashboard KPI tile rendered the raw float (e.g. `0.14648736342042862%`)
because the template literal `${data.current_coverage || 0}%` did no
formatting. Apply `.toFixed(1)` to both `current_coverage` and
`target_coverage` so the tile reads as e.g. `0.1%` / `80.0%`,
matching the convention already used in inventory.ts.

Regression test in dashboard.test.ts asserts the fractional input
renders as `0.1%` and never as the raw float.
TestHandler_getPurchaseDetails_NotFound_IsClientError set a nonexistent
Session.Role field causing go vet to fail: the Session struct carries only
UserID/Email; admin is resolved via HasPermissionAPI. Drop the bogus field
and confer admin through mockAuth.grantAdmin() so the handler reaches the
GetExecutionByID not-found branch it asserts on.

Also split multi-statement-per-line entries in handler_purchases_guards_test.go
that caused gofmt to fail the pre-commit hook.
@cristim
cristim force-pushed the fix/dashboard-coverage-formatting branch from e020748 to 92a1f28 Compare June 5, 2026 10:40
@cristim

cristim commented Jun 5, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim
cristim merged commit 92db4e7 into feat/multicloud-web-frontend Jun 5, 2026
5 checks passed
@cristim
cristim deleted the fix/dashboard-coverage-formatting branch July 27, 2026 11:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working impact/all-users Affects every user priority/p3 Polish / idea / may never ship severity/low Minor harm triaged Item has been triaged urgency/this-sprint Within the current sprint

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant