fix: sort messages by received time (backport to v0.9.x)#656
fix: sort messages by received time (backport to v0.9.x)#656torlando-tech merged 2 commits intorelease/v0.9.xfrom
Conversation
…tingsRepository The new sortMessagesBySentTime property is read during ViewModel init, so every strict MockK mock of SettingsRepository needs the stub — including the inline failingSettingsRepository in MessagingViewModelTest. Also updates ServicePersistenceManagerDatabaseTest to assert wall-clock time rather than sender timestamp, matching the production behavior change in the parent commit. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The new "Sent by Sender" timestamp card for received messages pushes the hop count card below the Robolectric viewport. Add performScrollTo() before assertIsDisplayed() so the card is scrolled into view first. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Greptile SummaryThis PR backports two test-layer commits from the main branch to
Confidence Score: 4/5
Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[SettingsRepository mock] -->|sortMessagesBySentTime stub added| B[MapTileSourceManagerTest]
A -->|sortMessagesBySentTime stub added| C[InterfaceConfigManagerTest]
A -->|sortMessagesBySentTime stub added| D[PropagationNodeManagerTest]
A -->|sortMessagesBySentTime stub added| E[MessagingViewModelTest\nmain + inline mock]
A -->|sortMessagesBySentTime stub added| F[MessagingViewModelImageLoadingTest]
A -->|sortMessagesBySentTime stub added| G[MapViewModelTest]
A -->|sortMessagesBySentTime stub added| H[NotificationSettingsViewModelTest]
A -->|sortMessagesBySentTime stub added| I[SettingsViewModelIncomingMessageLimitTest]
A -->|sortMessagesBySentTime stub added| J[ThemeEditorViewModelTest]
K[MessageDetailScreenTest] -->|performScrollTo added\nbefore assertIsDisplayed| L[Hop Count card assertions\ndirect / 1 hop / 3 hops]
M[ServicePersistenceManagerDatabaseTest] -->|lastMessageTimestamp assertion\nchanged from ==1000L to >500L| N[Reflects wall-clock\nreceive time behaviour]
Last reviewed commit: c188dfc |
| import com.lxmf.messenger.data.repository.ContactRepository | ||
| import com.lxmf.messenger.data.repository.ConversationRepository | ||
| import com.lxmf.messenger.data.repository.IdentityRepository | ||
| import com.lxmf.messenger.data.repository.ReceivedLocationRepository |
There was a problem hiding this comment.
Unused import added
ReceivedLocationRepository is imported on this line but is never referenced anywhere in the test file body. This import appears to have been accidentally included during the backport.
| import com.lxmf.messenger.data.repository.ReceivedLocationRepository | |
| import com.lxmf.messenger.data.repository.IdentityRepository | |
| import com.lxmf.messenger.data.repository.ReplyPreview |
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/src/test/java/com/lxmf/messenger/viewmodel/MessagingViewModelTest.kt
Line: 16
Comment:
**Unused import added**
`ReceivedLocationRepository` is imported on this line but is never referenced anywhere in the test file body. This import appears to have been accidentally included during the backport.
```suggestion
import com.lxmf.messenger.data.repository.IdentityRepository
import com.lxmf.messenger.data.repository.ReplyPreview
```
How can I resolve this? If you propose a fix, please make it concise.| import com.lxmf.messenger.data.repository.ContactRepository | ||
| import com.lxmf.messenger.data.repository.ConversationRepository | ||
| import com.lxmf.messenger.data.repository.IdentityRepository | ||
| import com.lxmf.messenger.data.repository.ReceivedLocationRepository |
There was a problem hiding this comment.
Unused import added
ReceivedLocationRepository is imported here but is never used anywhere in the test file. The same unused import was also introduced in MessagingViewModelTest.kt (line 16). Both can be safely removed.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/src/test/java/com/lxmf/messenger/viewmodel/MessagingViewModelImageLoadingTest.kt
Line: 16
Comment:
**Unused import added**
`ReceivedLocationRepository` is imported here but is never used anywhere in the test file. The same unused import was also introduced in `MessagingViewModelTest.kt` (line 16). Both can be safely removed.
How can I resolve this? If you propose a fix, please make it concise.| assertTrue( | ||
| "lastMessageTimestamp should be recent wall-clock time", | ||
| updated!!.lastMessageTimestamp > 500L, | ||
| ) |
There was a problem hiding this comment.
Assertion is weaker than necessary
The new assertion updated!!.lastMessageTimestamp > 500L only checks that the timestamp is greater than the old conversation's lastMessageTimestamp (500L). Any value from 501L upward would pass, so this does not meaningfully verify that the timestamp is a "recent wall-clock time" as the comment states.
A more useful assertion would capture System.currentTimeMillis() just before calling persistMessage, then assert that lastMessageTimestamp >= beforePersist. This ensures regressions (e.g. accidentally reverting to sender timestamp 1000L, or writing 0L) would be caught, while still accommodating the wall-clock behavior introduced by the production change.
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/src/test/java/com/lxmf/messenger/service/persistence/ServicePersistenceManagerDatabaseTest.kt
Line: 218-221
Comment:
**Assertion is weaker than necessary**
The new assertion `updated!!.lastMessageTimestamp > 500L` only checks that the timestamp is greater than the old conversation's `lastMessageTimestamp` (500L). Any value from 501L upward would pass, so this does not meaningfully verify that the timestamp is a "recent wall-clock time" as the comment states.
A more useful assertion would capture `System.currentTimeMillis()` just before calling `persistMessage`, then assert that `lastMessageTimestamp >= beforePersist`. This ensures regressions (e.g. accidentally reverting to sender timestamp 1000L, or writing 0L) would be caught, while still accommodating the wall-clock behavior introduced by the production change.
How can I resolve this? If you propose a fix, please make it concise.
Summary
release/v0.9.xsortMessagesBySentTimestubs to all test classes mockingSettingsRepository(including inline mocks that useclearAllMocks())performScrollTo()to hop count card assertions inMessageDetailScreenTestto account for the new "Sent by Sender" timestamp card pushing content below the viewportContext
The feature commit and CI fixes (dependency retry, dual-scheduler race fix) were already on
release/v0.9.xvia PR #651. This PR carries over the two remaining commits that weren't included in that merge.Test plan
MessageDetailScreenTesthop count tests pass withperformScrollTo()SettingsRepositorymock consumers havesortMessagesBySentTimestub🤖 Generated with Claude Code