Skip to content

test(messenger): one shared ChatViewModel fixture - #1924

Merged
bmc08gt merged 1 commit into
code/cashfrom
test/chat-viewmodel-fixture
Nov 2, 2026
Merged

bmc08gt merged 1 commit into
code/cashfrom
test/chat-viewmodel-fixture

Conversation

@bmc08gt

@bmc08gt bmc08gt commented Oct 31, 2026

Copy link
Copy Markdown
Collaborator

ChatViewModel has about 40 constructor parameters, and ten test classes in the messenger module each carried their own createViewModel with the full named-argument call. The planned ChatViewModel split adds parameters, and each one would mean editing all ten.

This adds chatViewModel(...) in ChatViewModelFixture.kt. Every dependency is a defaulted, named parameter (relaxed mocks, or the real empty instance where the type is a value such as E2eePolicy()); only the MainCoroutineRule dispatcher is required. The ten tests now pass only what they stub or assert on. Where the copies differed, the per-test value is an override at the call site; defaults are the common case. The tests keep their thin createViewModel wrappers, and unused imports left behind are removed.

Test-only: no production code changes. The messenger testDebugUnitTest task runs the same 1112 tests before and after, with identical names.

MuteChatAnalyticsTest and MuteChatViewerStateSeedTest match a ChatViewModel( grep but build MuteChatViewModel, so they are untouched.

Ten test classes each built ChatViewModel with a 40-argument named
constructor call. Every constructor parameter the planned ChatViewModel
split adds would mean editing all of them.

chatViewModel(...) in ChatViewModelFixture.kt defaults every dependency
to the value most of those copies used; each test now passes only the
collaborators it stubs or asserts on. Overrides are the values each
copy passed before, so no test changes behaviour.
@bmc08gt bmc08gt self-assigned this Oct 31, 2026
@github-actions github-actions Bot added the type: test Test additions or improvements label Oct 31, 2026
@bmc08gt
bmc08gt merged commit bb1230c into code/cash Nov 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: test Test additions or improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant