Skip to content

Fix flaky isLaterThanDays date test - #6690

Merged
gpunto merged 2 commits into
v6from
fix/v6-flaky-islaterthandays-test
Sep 10, 2026
Merged

gpunto merged 2 commits into
v6from
fix/v6-flaky-islaterthandays-test

Conversation

@gpunto

@gpunto gpunto commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Goal

DateExtensionsTests flakes on CI. The "exactly as old as specified days" case builds a date now - 5 days and expects isLaterThanDays(5 days) to be false, but isLaterThanDays reads the clock again internally, so it only holds when both reads land in the same millisecond. Any tick between them flips the result and fails the test.

Closes AND-1514

Implementation

  • Add a defaulted now: Date = Date() parameter to isLaterThanDays so the reference instant can be injected. Production callers use the default and are unchanged.
  • Derive every test's date from a single fixed now and pass it in, removing the wall-clock dependence from the whole suite.

Both are internal, so no public API change.

Testing

  • :stream-chat-android-client:testDebugUnitTest --tests "*DateExtensionsTests" passes; the boundary case is now deterministic.

Summary by CodeRabbit

  • Refactor
    • Improved date comparison consistency by allowing comparisons to use a specified reference date.
    • Updated internal date tests to use shared, consistent time values.

@gpunto gpunto added the pr:test Test-only changes label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled (or ignored for dependabot PRs).

🎉 Great job! This PR is ready for review.

@github-actions

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 5.26 MB 5.32 MB 0.05 MB 🟢
stream-chat-android-offline 5.49 MB 5.54 MB 0.05 MB 🟢
stream-chat-android-ui-components 10.64 MB 10.76 MB 0.11 MB 🟢
stream-chat-android-compose 12.87 MB 13.15 MB 0.28 MB 🟡

@gpunto
gpunto marked this pull request as ready for review September 10, 2026 09:47
@gpunto
gpunto requested a review from a team as a code owner September 10, 2026 09:47
@coderabbitai

coderabbitai Bot commented Sep 10, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: fd3270de-5fc7-4924-add6-98b7d5380089

📥 Commits

Reviewing files that changed from the base of the PR and between f3bbcd1 and adac9bd.

📒 Files selected for processing (2)
  • stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Date.kt
  • stream-chat-android-client/src/test/java/io/getstream/chat/android/client/extensions/internal/DateExtensionsTests.kt

Included review availability: Your plan provides up to 4 included reviews per hour; 2 remain after this review.


Walkthrough

Date.isLaterThanDays now accepts an optional comparison date. Date extension tests use shared reference values and pass the comparison date explicitly.

Changes

Date comparison updates

Layer / File(s) Summary
Reference date and test updates
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Date.kt, stream-chat-android-client/src/test/java/io/getstream/chat/android/client/extensions/internal/DateExtensionsTests.kt
Date.isLaterThanDays accepts an optional now parameter. Tests derive dates from shared now and fiveDaysInMillis values.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to adac9

The change makes date comparisons deterministic without changing existing default behavior. Targeted tests, including the five-day boundary, pass, so the PR is mergeable.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: fixing the flaky isLaterThanDays date test.
Description check ✅ Passed The description includes the goal, implementation details, linked issue, testing information, and API impact. UI sections are not relevant to this non-UI change.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
  • Fix all pre-merge checks with AI
✨ Finishing Touches 💡 2
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🛠️ Fix failing CI checks 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/v6-flaky-islaterthandays-test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

A rabbit reads each line,
The patch grows clear beneath the moon,
Small changes hop in place,
Tests guard the garden path,
Reviews bloom before the dawn.

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

@andremion andremion 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.

Looks good, the injected now makes the boundary case deterministic. One naming nit inline, optional.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
50.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@gpunto
gpunto merged commit 94c17cf into v6 Sep 10, 2026
18 of 19 checks passed
@gpunto
gpunto deleted the fix/v6-flaky-islaterthandays-test branch September 10, 2026 15:58
@stream-public-bot stream-public-bot added the released Included in a release label Sep 15, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v6.44.0

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

Labels

pr:test Test-only changes released Included in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants