mattermost-mobile-upstream/detox/e2e/support/ui
Guillermo Vayá 9e6f7144a3
Fix cross-device sync for attach logs preference (MM-67856) (#9667)
* Fix cross-device sync for attach logs preference (MM-67856)

WatermelonDB query .observe() only emits when records enter/leave the
result set, not when a field on an existing record changes. This caused
the attach logs toggle to not sync across devices after the initial
creation. Fix by subscribing to the individual record's .observe() via
switchMap, which emits on any field change.

Extract observePreferenceAsBool helper to app/queries/servers/preference.ts
and use it in both report_a_problem and quick_actions enhanced components.

Also adds unit tests, E2E tests, and debug logging for preference WS events.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* Address PR review feedback for attach logs feature

- Add testID to Report a Problem screen and use screen.back.button in
  Detox screen object to match existing settings screen patterns
- Remove unused REPORT_PROBLEM_CLOSE_BUTTON_ID export
- Omit preference values from debug logs to avoid logging large or
  sensitive data
- Rename attachLogsPref to attachLogsEnabled for clarity

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* address review requests

* Fix attach_logs detox tests

Tests 2 and 3 navigated to ChannelScreen directly after closing Settings
while still on the Account tab; added ChannelListScreen.open() first.

Test 4 was writing AllowDownloadLogs under LogSettings, but the server
field lives under SupportSettings, so apiUpdateConfig silently had no
effect and the toggle stayed visible. Corrected the section and added
device.reloadReactNative() so the client picks up the updated config on
next startup.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Address PR review feedback

- preferences.ts: prefix logDebug calls with handler name per repo
  convention.
- report_a_problem/index.test.tsx: wrap the post-update assertion in
  waitFor() so the test doesn't race the observable emission.
- detox report_problem screen: use toBeVisible() matcher in toBeVisible()
  instead of toExist(), matching method intent.
- attach_logs.e2e.ts: wrap test 4 body in try/finally so the
  AllowDownloadLogs rollback always runs, preventing config leaks into
  later suites if an assertion fails.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* use observewithcolumns

* Log early returns in preference WS handlers

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-21 12:10:36 +02:00
..
component [MM-67923] Add channel settings for shared channels (#9591) 2026-04-14 11:43:44 +02:00
screen Fix cross-device sync for attach logs preference (MM-67856) (#9667) 2026-04-21 12:10:36 +02:00