Skip to content

refactor: dedupe reports route, add PDF/CSV export tests, type frontend API client - #921

Open
devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787544347-qol-improvements
Open

devin-ai-integration[bot] wants to merge 1 commit into
mainfrom
devin/1787544347-qol-improvements

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Quality-of-life improvements, no behavior changes:

Backend — routes/reports.js dedupe + constants
All three report endpoints repeated the same ID-validation → verify-client-ownership → fetch-work-entries pipeline. Extracted it into a shared loadClientReportData(req, res, entryColumns, onSuccess) helper, plus sumHours(workEntries) and buildExportFilename(clientName, extension) utilities (with JSDoc). PDF layout magic numbers are now named constants (PDF_PAGE_BREAK_Y, PDF_LINE_START_X/END_X, PDF_SEPARATOR_INTERVAL). Error responses and query shapes are unchanged.

Backend — tests for reports.js (64% → 93% stmt coverage)
Added tests for the previously uncovered PDF export success path: response headers/filename, title/totals text, No description fallback, page-break behavior when doc.y exceeds the threshold, and separator lines every 5 entries. All 164 tests pass.

Frontend — typed API client
ApiClient methods returned untyped response.data. Each method now declares its actual response shape (matching backend wrappers, e.g. getClients(): Promise<{ clients: Client[] }>, createWorkEntry(...): Promise<{ message: string; workEntry: WorkEntry }>), and request payloads use the existing CreateClientRequest/UpdateWorkEntryRequest etc. from types/api.ts. Also replaced an inline ad-hoc entry type in DashboardPage with WorkEntryWithClient, which surfaced (and fixes) a string | null vs string | undefined mismatch.

Verified: cd backend && npm test (164 passing), cd frontend && npx eslint src/ clean, npm run build succeeds.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/29fe3065d49c499f80d84c81b6e88515

@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

@sonarqubecloud

Copy link
Copy Markdown

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