Skip to content

refactor: quality-of-life improvements — test coverage, type safety, reduce duplication#776

Open
devin-ai-integration[bot] wants to merge 4 commits into
mainfrom
devin/1780891385-qol-improvements
Open

refactor: quality-of-life improvements — test coverage, type safety, reduce duplication#776
devin-ai-integration[bot] wants to merge 4 commits into
mainfrom
devin/1780891385-qol-improvements

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Jun 8, 2026

Summary

Three targeted quality improvements, no functional changes:

  1. reports.js test coverage: 64% → 94% — Added 7 tests covering the PDF generation success path (content rendering, empty entries, page overflow at y>700, separator lines every 5 entries, null descriptions) and CSV writer verification (correct entries passed to writeRecords, header/filename configuration). Remaining uncovered lines (127-134) are the res.download callback which requires a real filesystem file. Test helpers (setupClientAndEntries, setupPdfMock, requestPdfAndGetMock) reduce mock duplication.

  2. DashboardPage @ts-expect-error removal — Migrated 3 Grid usages from deprecated v1 item xs={12} prop syntax to v2 size={{ xs: 12 }} API, consistent with how ReportsPage already uses Grid.

  3. Shared getApiErrorMessage utility — Extracted the repeated error extraction pattern:

    // Before (repeated 8× across 3 pages):
    const error = err as { response?: { data?: { error?: string } } };
    setError(error.response?.data?.error || 'Failed to ...');
    
    // After:
    setError(getApiErrorMessage(err, 'Failed to ...'));

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/3ebb41e8a4f44659b6d75522cc44b0c6

…reduce duplication

- Improve reports.js test coverage from 64% to 94% with PDF generation
  success-path tests, CSV writer verification, and edge case coverage
- Fix DashboardPage @ts-expect-error suppressions by migrating Grid
  from deprecated item/xs props to Grid2 size prop API
- Extract shared getApiErrorMessage utility to replace 8 duplicated
  inline error type casts across ClientsPage, WorkEntriesPage, LoginPage
- Add explicit radix parameter (10) to all parseInt calls in backend routes
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment, CI, and merge conflict monitoring

Extract setupClientAndEntries, setupPdfMock, and getLastPdfInstance
helpers to deduplicate mock setup across PDF/CSV export tests.
The parseInt radix changes touched lines inside already-duplicated route
handler blocks, causing SonarCloud to flag them as new duplication (4.3%
vs 3% threshold). Reverting this low-impact improvement to pass CI.
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Jun 8, 2026

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.

0 participants