feat(finance): add expense save toasts#34
Merged
Conversation
- Add Vitest and Node ambient types to the finance app tsconfig. - Update test mocks for TypeScript 6 DOM and unused-parameter checks. - Use browser-safe timeout inference instead of NodeJS.Timeout.
- Replace new-expense success redirects with Sonner success toasts. - Reset visible form state through useExpenseFields without refetching bootstrap data. - Cover success, failure, validation, pro-rata, and autocomplete flows.
ItsThompson
commented
Jul 4, 2026
- Branch directly on isProRata and return the kind literal, dropping the redundant submit-time snapshot consts since the async closure already captures render-scoped state - Move SubmittedExpenseKind into its own types.ts and keep isProRata as the single toggle source of truth - Replace the deprecated FormEvent type with SyntheticEvent<HTMLFormElement>
- Add toLocalISODate util that formats a Date (default now) as a local YYYY-MM-DD string, avoiding UTC off-by-one from toISOString - Replace the private todayISO in useExpenseFields with the shared util - Cover the util with injected fixed-date and default-now tests
- Extract shared fixtures, a fetch-mock builder, and query helpers into new-expense __tests__/test-utils and refactor the three specs to use them - Remove per-file duplicated mock data and handlers without weakening any assertion - Replace the double-cast IntersectionObserverEntry with a buildIntersectionObserverEntry helper in the DashboardOutline test
ItsThompson
commented
Jul 4, 2026
- Move new-expense mock data and the fetch mock into a dedicated __mocks__ folder (fixtures + fetch + barrel) - Build the user and tag fixtures with the shared @gofin/test-utils factories instead of inline literals - Keep test-utils for shared test functions only (render, waiters, fetch-call query helpers)
- logExpense waits for the success toast (standard vs pro-rata) instead of a /dashboard redirect - specs that verify dashboard state now navigate to /dashboard explicitly before asserting - inline Log Expense submits assert the "Expense saved" toast, keeping the same coverage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Expense savedandExpense schedule saved, plus a genericFailed to save expensetoast on API/network failureuseExpenseFields.reset(...)instead of hand-copying defaultstoLocalISODateutil intosrc/lib/date-utils.tsand reuse it inuseExpenseFields, removing duplicated local-date formattingSubmittedExpenseKindinto a dedicatedtypes.tsand replace the deprecatedFormEventwithSyntheticEvent<HTMLFormElement>__tests__/test-utils.tsx, and add abuildIntersectionObserverEntryhelper in the dashboard outline testtypes: ["vitest/globals", "node"]intsconfig.app.json(the app typecheck compiles test files undersrc, which useglobaland un-imported vitest globals)Verification
cd frontend/apps/finance && npx tsc -p tsconfig.app.json --noEmit→ 0 errorscd frontend/apps/finance && npm run test→ 38 files, 426 tests passedcd frontend/apps/finance && npm run test -- --coverage→ thresholds met (stmts 92.14, branch 85.11, funcs 88.94, lines 93.65)cd frontend/apps/finance && npm run lint→ 0 errorscd frontend/apps/finance && npm run build→ built successfully