test: unit tests for RunningClockDatePicker - #3300
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3300 +/- ##
=======================================
Coverage 99.98% 99.98%
=======================================
Files 192 192
Lines 6191 6191
Branches 1159 1159
=======================================
Hits 6190 6190
Misses 1 1 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds a renderer-unit test suite for RunningClockDatePicker to verify its “track system clock / pause while open / buffer edits / cleanup on unmount” behavior. The PR also removes backend delete endpoints and associated service logic for transactions and transaction groups, which is not described in the PR metadata or the linked issue.
Changes:
- Add Vitest (happy-dom) unit tests for
RunningClockDatePicker, including fake-timer interval behavior and open/close buffering semantics. - Remove
removeTransactionand theDELETE /transactions/:idcontroller endpoint, along with corresponding unit tests. - Remove
removeTransactionGroupand theDELETE /transaction-groups/:idcontroller endpoint, along with corresponding unit tests and imports.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| front-end/src/tests/renderer/components/RunningClockDatePicker.spec.ts | New fake-timer unit tests covering RunningClockDatePicker ticking, pause/resume, buffering, and unmount cleanup behavior. |
| back-end/apps/api/src/transactions/transactions.service.ts | Removes removeTransaction service method. |
| back-end/apps/api/src/transactions/transactions.service.spec.ts | Removes unit tests for removeTransaction. |
| back-end/apps/api/src/transactions/transactions.controller.ts | Removes the DELETE /transactions/:id endpoint. |
| back-end/apps/api/src/transactions/transactions.controller.spec.ts | Removes controller tests for deleting transactions. |
| back-end/apps/api/src/transactions/groups/transaction-groups.service.ts | Removes removeTransactionGroup service method (and related import). |
| back-end/apps/api/src/transactions/groups/transaction-groups.service.spec.ts | Removes unit tests and import for transaction-group deletion behavior. |
| back-end/apps/api/src/transactions/groups/transaction-groups.controller.ts | Removes the DELETE /transaction-groups/:id endpoint. |
| back-end/apps/api/src/transactions/groups/transaction-groups.controller.spec.ts | Removes controller tests for removing a transaction group. |
Suppressed comments (1)
back-end/apps/api/src/transactions/transactions.service.ts:865
- This PR removes the TransactionsService.removeTransaction() method (and related behavior/notifications), but the PR title/description and linked issue (#3237) describe only adding front-end unit tests. If these backend API changes are intentional, the PR description/title (and possibly the linked issue) should be updated to reflect the breaking API/service change, or the backend removal should be split into a separate PR.
return Array.from(results.values());
}
/* Cancel the transaction if the valid start has not come yet. */
async cancelTransaction(id: number, user: User): Promise<boolean> {
await this.cancelTransactionWithOutcome(id, user);
return true;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Covers issue #3237 (manual test 7.1.7): verifies the valid-start time picker tracks the system clock via setInterval, pauses while the menu is open, buffers user edits, and cleans up on unmount. Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
03fa988 to
269833c
Compare
Signed-off-by: John Bair <john.bair@swirldslabs.com> Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.
Suppressed comments (1)
front-end/src/tests/renderer/components/RunningClockDatePicker.spec.ts:181
- Asserting
vi.getTimerCount() === 0after unmount is brittle because unrelated timers (from Vue Test Utils / happy-dom / other stubs) can exist even if this component cleared its own interval. Consider capturing the initial timer count before mount and asserting it returns to that baseline afterwrapper.unmount(), or spy onsetInterval/clearIntervalto ensure the created interval is cleared.
// At least one interval must be running while the component is mounted.
expect(vi.getTimerCount()).toBeGreaterThanOrEqual(1);
wrapper.unmount();
// After unmount the interval must be cleared — no pending timers remain.
expect(vi.getTimerCount()).toBe(0);
Description:
Adds a Vitest renderer unit test suite for
RunningClockDatePicker(the valid-start time picker in the transaction form). Usesvi.useFakeTimers()/vi.advanceTimersByTime()to verify the component automatically tracks the system clock, pauses updates while the picker menu is open, buffers user edits until close, and clears its interval on unmount. See the issue for the full test-case specification.Related issue(s):
Fixes #3237
Checklist