Skip to content

CodeRabbit Generated Unit Tests: Add unit tests for PR changes#3688

Open
coderabbitai[bot] wants to merge 1 commit into
mainfrom
coderabbitai/utg/4ac094f
Open

CodeRabbit Generated Unit Tests: Add unit tests for PR changes#3688
coderabbitai[bot] wants to merge 1 commit into
mainfrom
coderabbitai/utg/4ac094f

Conversation

@coderabbitai

@coderabbitai coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown

Unit test generation was requested by @t3dotgg.

The following files were modified:

  • apps/mobile/src/features/home/homeListItems.test.ts
  • apps/mobile/src/features/home/homeThreadList.test.ts
  • apps/mobile/src/lib/time.test.ts

Note

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 relativeTime formatting.

homeThreadList.test.ts gains tests for buildHomeThreadGroups recentThreads: 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 fixed now, makePendingTask, and related contract IDs.

homeListItems.test.ts updates fixtures so groups expose recentThreads, adds makeGroupWithRecentCount, and asserts buildHomeListLayout uses 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.ts is new and documents relativeTime edge 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 relativeTime

  • Adds tests for buildHomeListLayout in homeListItems.test.ts covering pagination baselines driven by recentThreads, including show-more/show-less behavior and baseline clamping to page size.
  • Adds tests for buildHomeThreadGroups in homeThreadList.test.ts covering recency filtering (5-day window, fallback to 3 threads, exact cutoff, empty groups, and search query bypass).
  • Adds a new test file time.test.ts for relativeTime, asserting output across sub-minute, minute, hour, and day boundaries using fake timers.

Macroscope summarized b987aae.

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Author

Important

Review skipped

This 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 configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a62e277a-7e8f-4569-b0c0-058d9660b488

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L 100-499 changed lines (additions + deletions). labels Jul 4, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 3 potential issues.

Fix All in Cursor

❌ 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");
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

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"]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b987aae. Configure here.

hiddenCount: 8,
canShowLess: false,
});
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit b987aae. Configure here.

@macroscopeapp

macroscopeapp Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant