Skip to content

Fix flaky isLaterThanDays date test - #6691

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

gpunto merged 2 commits into
developfrom
fix/develop-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.

Port of #6690 to develop.

Part of 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

  • Tests
    • Improved date-related test consistency by using a shared reference time.
    • Updated coverage for date comparisons with an explicitly provided current time.

@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 the PR is bot-authored.
  • An issue is linked (Linear ticket or GitHub issue), or the PR is bot-authored.

🎉 Great job! This PR is ready for review.

@github-actions

github-actions Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-chat-android-client 6.11 MB 6.11 MB 0.00 MB 🟢
stream-chat-android-ui-components 11.41 MB 11.41 MB 0.00 MB 🟢
stream-chat-android-compose 13.09 MB 13.09 MB 0.00 MB 🟢

@gpunto
gpunto marked this pull request as ready for review September 10, 2026 09:46
@gpunto
gpunto requested a review from a team as a code owner September 10, 2026 09:46
@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: 3cae0d37-eb3c-44f4-84d6-84ac52f590f9

📥 Commits

Reviewing files that changed from the base of the PR and between 27dd406 and 634cb96.

📒 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; 3 remain after this review.


Walkthrough

Date.isLaterThanDays now accepts an optional reference date. Date extension tests use a shared reference time to construct deterministic past, present, and future scenarios.

Changes

Date comparison

Layer / File(s) Summary
Date comparison reference
stream-chat-android-client/src/main/java/io/getstream/chat/android/client/extensions/internal/Date.kt
Date.isLaterThanDays accepts an optional now parameter and uses it for comparison.
Deterministic comparison tests
stream-chat-android-client/src/test/java/io/getstream/chat/android/client/extensions/internal/DateExtensionsTests.kt
Tests use shared time values and pass now explicitly across threshold, past, present, future, zero-threshold, and large-difference cases.

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

Suggested reviewers: velikovpetar

Merge Risk: ⚪ Minimal · up to 634cb

The helper now supports an injectable reference time while preserving current production behavior, and deterministic tests cover the comparison boundary. No merge-blocking risk remains.

🚥 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 identifies the main change: fixing the flaky isLaterThanDays date test.
Description check ✅ Passed The description includes the goal, implementation details, testing information, issue reference, and API impact. UI sections and checklists are omitted, but they 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 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/develop-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 checks the ticking day
With one fixed clock to guide the way
Past dates hop and futures gleam
Thresholds line up in a tidy stream
The tests now rest on time made still

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.

Same change as #6690, byte for byte. Approving so the port is not blocked. The naming nit I left on #6690 applies here too, if you decide to take it.

@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 added this pull request to the merge queue Sep 10, 2026
Merged via the queue into develop with commit cde4921 Sep 10, 2026
18 of 19 checks passed
@gpunto
gpunto deleted the fix/develop-flaky-islaterthandays-test branch September 10, 2026 16:43
@stream-public-bot stream-public-bot added the released Included in a release label Sep 24, 2026
@stream-public-bot

Copy link
Copy Markdown
Contributor

🚀 Available in v7.12.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