Skip to content

[AAASM-3514] ♻️ (dashboard): Harden Audit Log page — Sonar fixes + tests#1186

Merged
Chisanan232 merged 4 commits into
masterfrom
v0.0.1/AAASM-3514/refactor/audit_sonar_tests
Jun 21, 2026
Merged

[AAASM-3514] ♻️ (dashboard): Harden Audit Log page — Sonar fixes + tests#1186
Chisanan232 merged 4 commits into
masterfrom
v0.0.1/AAASM-3514/refactor/audit_sonar_tests

Conversation

@Chisanan232

Copy link
Copy Markdown
Contributor

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.ts L93 — typescript:S6551: p.operation ?? ''
    could stringify a non-string operation as [object Object]. Now narrowed to
    typeof p.operation === 'string' ? p.operation : '' before .toUpperCase().
  • dashboard/src/features/audit/logs.ts L93 — typescript:S4624: the nested
    byte-size template literal is lifted into a named sizeSuffix const.
  • dashboard/src/pages/AuditLogPage.tsx L188 — typescript:S3358: the nested
    isError ? … : isLoading ? … : <table> ternary is replaced by a body
    ReactNode chosen with an explicit if/else chain before the return.

Tests:

  • logs.test.tsxpayloadSummary 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; zero-seq auditEventHref.
  • AuditLogPage.test.tsx — allow / em-dash decision chips, unknown event-type
    label fallback, agent-select option set, combined type + search filtering,
    loading state, agent link.

Type of Change

  • ♻️ Refactoring

Breaking Changes

  • No

For string operation values the summary output is byte-for-byte identical;
only previously-malformed non-string inputs change from [OBJECT OBJECT] to an
empty verb.

Related Issues

  • Related Jira ticket: AAASM-3514

Testing

  • Unit tests added / updated
  • Manual testing performed

Validation (in dashboard/): pnpm type-check, pnpm lint, pnpm build, and
pnpm test (147 files / 1322 tests) all green.

Checklist

  • Code follows project style guidelines
  • Self-review of the diff completed
  • Documentation updated if behaviour changed (n/a — no behaviour change)
  • All CI checks passing
  • Commits are small and follow the Gitmoji convention

🤖 Generated with Claude Code

Chisanan232 and others added 4 commits June 21, 2026 14:05
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

codecov Bot commented Jun 21, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 78.57143% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
dashboard/src/pages/AuditLogPage.tsx 76.00% 4 Missing and 2 partials ⚠️

📢 Thoughts on this report? Let us know!

@Chisanan232

Copy link
Copy Markdown
Contributor Author

🔎 Review (Claude Code) — ready for approval

CI: ✅ 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):

  • audit/logs.ts L93: S6551typeof p.operation === 'string' ? p.operation : '' (no more [object Object] for non-string operation); S4624 → nested byte-size template lifted into a named sizeSuffix const
  • AuditLogPage.tsx L188: S3358 → nested ternary flattened into an if/else if/else choosing a body: ReactNode, rendered as {body} (identical output)

Tests (2-2): +20 cases — logs.test.tsx (object/missing/non-string payload fields, MB-suffix, tool/network/approval branches, truncation; extractDecision/auditEventHref edges) + AuditLogPage.test.tsx (allow/em-dash chips, unknown-type fallback, agent-select, combined type+search filtering, loading). Suite 1322 pass; lint/type-check/build clean.

Verdict: Scope-complete, correct, green. The one intentional behaviour note (non-string operation → empty verb instead of [OBJECT OBJECT]) is the S6551 fix itself. Ready to approve & merge.

@Chisanan232 Chisanan232 merged commit 8d8ef49 into master Jun 21, 2026
37 checks passed
@Chisanan232 Chisanan232 deleted the v0.0.1/AAASM-3514/refactor/audit_sonar_tests branch June 21, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant