Files
aiturk-mobil/app
M57andM57 e8025efcde fix(#298): internationalize ConnectViewModel strings, fix null-assert crash on profile selector (#307)
* fix(#298): internationalize ConnectViewModel strings, fix null-assert crash on profile selector

E1: Add all connect error resources to strings.xml for i18n readiness
E2: Migrate ConnectViewModel to AndroidViewModel, replace all hardcoded
    user-facing strings with getString(R.string.*) calls
F1: Replace state.selectedProfile!! with .?.let { } pattern in
    ConnectScreen.kt to eliminate NPE risk on mutable state copy

Closes #298

* fix(#298): update test files for AndroidViewModel constructor

Update ConnectViewModelTest.kt and E2eIntegrationTest.kt to pass
mock Application to the new ConnectViewModel(app) constructor.
Add getString() MockK stubs matching the string resource keys.

* fix(#298): add missing LocalContext import and restore connect_pairing_string

Two compilation errors:
- ConnectScreen.kt was missing import for LocalContext
- strings.xml was missing connect_pairing_string resource
  (accidentally removed in earlier patch)

* fix(#298): extract ViewModelFactory to avoid composable-in-non-composable error

LocalContext.current cannot be called inside a viewModel { } factory
lambda because the lambda is not @Composable. Fix by extracting a
ConnectViewModelFactory class and using run { } to capture the
Application value at the composable call site before passing to
the factory constructor.

* fix(#298): fix MockK varargs matching in test stubs

getString(int, Object...) takes varargs. MockK's any<Int>() and
any<String>() didn't match the vararg Object... slot. Changed to
any() (untyped) which matches correctly.

* fix(#298): fix MockK answers — arg indexing was wrong

In getString(int, Object...), firstArg is the resource ID,
secondArg is the format argument. Using firstArg<Int>() in
the answers block was returning the res ID, not 500/etc.
Changed to secondArg<Any>().

* fix(#298): replace getString(int,Object...) with String.format(getString(int),...)

Avoid MockK varargs matching issues by calling app.getString(int)
for the format template and String.format() to apply args.
Simplifies test stubs to pure getString(int) returns.

---------

Co-authored-by: M57 <hy4ri@users.noreply.github.com>
2026-06-22 21:38:28 +03:00
..
2026-06-22 21:35:40 +03:00