CodeRabbit Generated Unit Tests: Add unit tests for PR changes#3688
CodeRabbit Generated Unit Tests: Add unit tests for PR changes#3688coderabbitai[bot] wants to merge 1 commit into
Conversation
|
Important Review skippedThis PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback. ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Want fixes drafted automatically? Bugbot Autofix can create code changes for findings. A team admin can enable Autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit b987aae. Configure here.
|
|
||
| it("clamps timestamps in the future to '<1m' rather than a negative duration", () => { | ||
| expect(relativeTime(new Date(NOW + 60_000).toISOString())).toBe("<1m"); | ||
| }); |
There was a problem hiding this comment.
relativeTime tests expect wrong strings
Medium Severity
The relativeTime function in apps/mobile/src/lib/time.ts returns 'now' for invalid inputs and timestamps under 10s, and 'Ns' for 10-59s deltas. This conflicts with the new tests, which expect '<1m>' for invalid, current, sub-minute, and future timestamps.
Reviewed by Cursor Bugbot for commit b987aae. Configure here.
|
|
||
| const group = buildGroups([project], threads)[0]; | ||
| // Default view trims to recent threads... | ||
| expect(group?.recentThreads.map((thread) => thread.id)).toEqual(["recent-1", "recent-2"]); |
There was a problem hiding this comment.
Tests map undefined recentThreads
High Severity
The new buildHomeThreadGroups tests are failing with undefined.map() errors. It appears the function's return object is missing the recentThreads property that the tests expect.
Reviewed by Cursor Bugbot for commit b987aae. Configure here.
| hiddenCount: 8, | ||
| canShowLess: false, | ||
| }); | ||
| }); |
There was a problem hiding this comment.
Layout tests ignore recentThreads
Medium Severity
New buildHomeListLayout cases assume a recency baseline from recentThreads (e.g. two visible threads and show-less back to two), but buildHomeListLayout only slices group.threads with HOME_INITIAL_VISIBLE_THREADS and nextGroupDisplayState show-less still resets to six.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit b987aae. Configure here.
ApprovabilityVerdict: Approved Test-only changes that add unit tests for home list and time utilities. No production code is modified, so there is no runtime impact. Open review comments flag potential test correctness issues, but these would surface as CI failures rather than production bugs. You can customize Macroscope's approvability policy. Learn more. |


Unit test generation was requested by @t3dotgg.
The following files were modified:
apps/mobile/src/features/home/homeListItems.test.tsapps/mobile/src/features/home/homeThreadList.test.tsapps/mobile/src/lib/time.test.tsNote
Low Risk
Test-only changes with no production code modifications in this diff.
Overview
Adds mobile unit test coverage for home thread grouping, list pagination tied to recent threads, and
relativeTimeformatting.homeThreadList.test.tsgains tests forbuildHomeThreadGroupsrecentThreads: 5-day recency window, 3-thread fallback when nothing is recent, inclusive cutoff, empty groups (with pending tasks), and skipping recency while searching. Helpers add a fixednow,makePendingTask, and related contract IDs.homeListItems.test.tsupdates fixtures so groups exposerecentThreads, addsmakeGroupWithRecentCount, and assertsbuildHomeListLayoutuses the recent count as the default visible baseline (capped by page size), show-more/show-less behavior, and when the show-more row appears.time.test.tsis new and documentsrelativeTimeedge cases: invalid input, sub-minute<1m, future timestamps clamped, and minute/hour/day steps with fake timers.Reviewed by Cursor Bugbot for commit b987aae. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Add unit tests for home list layout, thread grouping recency logic, and
relativeTimebuildHomeListLayoutin homeListItems.test.ts covering pagination baselines driven byrecentThreads, including show-more/show-less behavior and baseline clamping to page size.buildHomeThreadGroupsin homeThreadList.test.ts covering recency filtering (5-day window, fallback to 3 threads, exact cutoff, empty groups, and search query bypass).relativeTime, asserting output across sub-minute, minute, hour, and day boundaries using fake timers.Macroscope summarized b987aae.