[AAASM-3514] ♻️ (dashboard): Harden Audit Log page — Sonar fixes + tests#1186
Conversation
Coerce a non-string `operation` to '' instead of stringifying an object as `[object Object]` (typescript:S6551), and lift the nested byte-size template into a `sizeSuffix` const (typescript:S4624). String inputs are unchanged. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Extract the error → loading → table render branch into a `body` ReactNode chosen by an explicit if/else, removing the nested ternary (typescript:S3358). No render-output change. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add payloadSummary FileOp coverage (object-valued / missing / non-string operation, MB suffix on/off), ToolCall error / NetworkCall / ApprovalEvent branches, oversized-dump truncation, extractDecision non-string/empty/ non-object payloads, and a zero-seq auditEventHref case. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Add coverage for the allow / em-dash decision chips, unknown event-type label fallback, agent-select option set, combined type + search filtering, the loading state, and the agent link — exercising the flattened body branch and decision-meta paths. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
🔎 Review (Claude Code) — ready for approvalCI: ✅ All green — 0 failures (codecov/patch acceptance is non-blocking). Scope vs AAASM-3514: ✅ Fixes all 3 listed SonarCloud issues, refactor-only (string-input output unchanged):
Tests (2-2): +20 cases — Verdict: Scope-complete, correct, green. The one intentional behaviour note (non-string |
Description
Fixes the SonarCloud Reliability/Maintainability issues reported on the dashboard
Audit Log page and broadens its test coverage. Refactor-only — no behaviour
change for the existing (string-valued) payload inputs.
SonarCloud fixes:
dashboard/src/features/audit/logs.tsL93 —typescript:S6551:p.operation ?? ''could stringify a non-string
operationas[object Object]. Now narrowed totypeof p.operation === 'string' ? p.operation : ''before.toUpperCase().dashboard/src/features/audit/logs.tsL93 —typescript:S4624: the nestedbyte-size template literal is lifted into a named
sizeSuffixconst.dashboard/src/pages/AuditLogPage.tsxL188 —typescript:S3358: the nestedisError ? … : isLoading ? … : <table>ternary is replaced by abodyReactNodechosen with an explicitif/elsechain before the return.Tests:
logs.test.tsx—payloadSummaryFileOp coverage (object-valued / missing /non-string
operation, MB suffix on/off), ToolCall error / NetworkCall /ApprovalEvent branches, oversized-dump truncation;
extractDecisionnon-string / empty / non-object payloads; zero-seq
auditEventHref.AuditLogPage.test.tsx— allow / em-dash decision chips, unknown event-typelabel fallback, agent-select option set, combined type + search filtering,
loading state, agent link.
Type of Change
Breaking Changes
For string
operationvalues the summary output is byte-for-byte identical;only previously-malformed non-string inputs change from
[OBJECT OBJECT]to anempty verb.
Related Issues
Testing
Validation (in
dashboard/):pnpm type-check,pnpm lint,pnpm build, andpnpm test(147 files / 1322 tests) all green.Checklist
🤖 Generated with Claude Code