mattermost-mobile/app/utils
Scott Bishel ca117805be
Add DialogRouter for Interactive Dialog to Apps Form migration (#9114)
* feat: Add DialogRouter for Interactive Dialog to Apps Form migration

Implements feature flag-controlled routing between legacy InteractiveDialog and modern AppsForm components to enable gradual migration.

Key Features:
- DialogRouter component with React.memo optimization for performance
- InteractiveDialogAdapter with WeakMap caching for form conversion
- Complete dialog/AppForm conversion utilities with validation
- Graceful fallback to legacy InteractiveDialog on conversion errors
- Type-safe implementation with optional subtype field support

Architecture:
- Feature flag controlled: FeatureFlagInteractiveDialogAppsForm
- Performance optimized: WeakMap cache, useMemo, useCallback patterns
- Error resilient: try/catch with fallback handling
- Mobile-first: Designed for React Native Navigation

Testing:
- 94 comprehensive unit tests covering all scenarios
- Cache behavior, error handling, edge cases
- Mock implementations for component integration
- Full TypeScript coverage with proper error cases

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* i18n-extract

* Add interactive dialog e2e tests and fix testID support for mobile form elements

This commit adds comprehensive e2e testing for interactive dialogs and fixes critical testID issues that were preventing form element interactions in mobile tests.

Key changes:
- Fix UserList component to use dynamic testID prop instead of hardcoded 'create_direct_message.user_list.user_item'
- Add testID support to BoolSetting and RadioSetting components for AppsForm elements
- Add testID support to ChannelListRow in IntegrationSelector for consistent channel selection
- Remove problematic disabled send button validation that was causing test failures
- Add comprehensive interactive dialog test suite with text, select, multiselect, and boolean field tests
- Implement wildcard testID discovery for dynamic user/channel element finding
- Add webhook server health check functionality matching webapp patterns
- Add Command and Webhook server API modules for test infrastructure
- Enable MM_FEATUREFLAGS_InteractiveDialogAppsForm feature flag in Detox config
- Optimize test performance by reducing unnecessary wait times
- Correct testID patterns from InteractiveDialogElement.* to AppFormElement.*

TestID chain fixes enable proper element discovery:
IntegrationSelector → ServerUserList → UserList → UserListRow → UserItem
All components now properly pass through and construct testID chains for e2e testing.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix ESLint errors in interactive dialog tests and components

- Remove console.log statements and replace with comments
- Replace for-await loops with sequential try-catch blocks to avoid no-await-in-loop violations
- Add missing dependency 'testID' to RadioSetting useMemo hook
- Fix UserList useCallback dependencies to match actual usage
- Add missing newlines at end of files
- Remove duplicate getBooleanDialog function definition in webhook_utils.js
- Fix trailing spaces and formatting issues

All lint and TypeScript checks now pass.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix TypeScript errors in interactive dialog test files

- Add null checks for array access in boolean_fields.e2e.ts and text_fields.e2e.ts to prevent 'string | undefined' errors
- Replace RegExp patterns with string patterns in select_fields.e2e.ts since Detox by.id() expects strings
- Add proper null checking for array elements before using them in element selection
- All test files now compile without TypeScript errors

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Fix useCallback dependencies in UserList component

- Remove unnecessary 'style' dependency from renderNoResults useCallback
- Fix React hooks/exhaustive-deps ESLint warning
- Ensures proper dependency tracking for useCallback optimization

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* cleanup

* cleanup

* fix tests

* Replace webhook-based interactive dialog tests with plugin-based versions

- Remove webhook server dependency from dialog tests
- Add plugin-based test files using /dialog commands
- Tests now use mattermost-plugin-demo instead of webhook_server.js
- Remove webhook and command support utilities
- Update screen and server API support for plugin-based testing
- Clean up debug logging and unnecessary comments

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Update text_fields_plugin.e2e.ts

* Update webhook_utils.js

* add lf to eof

* Implement dynamic plugin installation and CSRF token handling for Detox tests

- Add DemoPlugin constants with dynamic version fetching from GitHub releases API
- Implement CSRF token handling in HTTP client following Cypress pattern
- Add server configuration functions (apiUpdateConfig, shouldHavePluginUploadEnabled)
- Update interactive dialog tests to use plugin-based approach with shared constants
- Fix naming conventions to follow established PascalCase/camelCase patterns

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix bad merge

* updates for new build name

* fix spacing lint issue

* Security: Fix information disclosure and SSRF vulnerabilities

- Prevent exposure of internal error messages in interactive dialog submissions
- Remove form structure enumeration in apps form error handling
- Add URL validation to prevent SSRF in plugin installation (test code)

Addresses Dryrun security scan findings.

* Update i18n strings for security fixes

* Improve plugin installation verification in interactive dialog tests

- Add error checking after plugin installation to fail fast with clear errors
- Verify plugin is actually active before running tests
- Add alert dismissal in afterEach to prevent cascading test failures
- Increase wait time for plugin initialization to 2 seconds

This fixes CI failures where the plugin installation silently failed,
causing tests to proceed and fail with "Plugin for /dialog is not working"
error alerts that blocked subsequent tests.

* Use linux-amd64 plugin build and add environment logging

  - Change demo plugin download to use linux-amd64 variant instead of generic tar.gz
    This is more reliable for CI environments running on Linux x86_64
  - Add environment logging (platform, arch, Node version, test server) at test start
  - Add specific error message for Cloudflare 524 timeouts with actionable solutions

  These changes help debug CI failures and should reduce plugin installation timeouts.

* Improve plugin installation with version checking and debugging

- Add comprehensive debug logging to track plugin installation status
  - Log target version, download URL, and current plugin state
  - Log installation actions taken (enable, remove, install)
  - Log final plugin status with version verification
- Fix plugin installation logic to handle version mismatches
  - Now removes old plugin versions before installing new ones
  - Only reactivates inactive plugins if version matches
  - Requires version parameter for proper version checking
- Add version validation to ensure correct plugin version is active
- Add detailed status messages for all installation paths

This helps diagnose plugin installation issues including architecture
mismatches and version upgrade problems.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Change plugin version mismatch from error to warning

Allow tests to continue even when plugin version doesn't match expected
version. This helps determine if the plugin commands work correctly
despite version metadata discrepancies.

The test will now log a warning but continue execution to verify if
/dialog commands are registered and functional.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Add plugin enable logging and fix SSRF vulnerability in test code

Plugin API improvements:
- Add detailed logging for enable plugin API response (status, data, errors)
- Add immediate status check after enable to verify activation
- Switch back to linux-amd64 architecture for plugin downloads
- Fix SSRF vulnerability by removing arbitrary URL parameter
- Make apiUploadAndEnablePlugin DemoPlugin-specific

Test file updates:
- Update all test files to use simplified API without url/id params
- Remove unused DemoPlugin imports from test files
- Only basic_dialog_plugin.e2e.ts retains detailed debug logging

This will help diagnose why plugins are not activating after the enable
API call succeeds.

* Add robust plugin installation with fallback and 524 timeout handling

- Try to activate existing plugin first before downloading new version
- If download/install fails, fall back to activating existing plugin
- Handle 524 Cloudflare timeout errors by checking if plugin activated anyway
- Never remove old plugin before successful new installation (maintain fallback)
- Add comprehensive logging at each step for debugging
- Return proper error format with message field for test detection

This handles the CI infrastructure issue where Cloudflare times out during
plugin enable (HTTP 524) by checking if the plugin is actually active
despite the timeout, and falling back to existing plugins when downloads fail.

* Add server config logging to debug plugin activation timeouts

Check and log EnableGifPicker and EnablePublicLink settings before
plugin activation to determine if missing config is causing the
2+ minute activation timeouts (524 errors).

* minor fixes

* couple tweeks

* Combine dialog router tests in 1 spec to avoid race condition. (#9269)

* Simplify plugin disabling condition

* dont depend on secondary status check

* fix merge issues, add config setting

* disable plugin after tests, cleanup

* lint fixes

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Mattermost Build <build@mattermost.com>
Co-authored-by: yasserfaraazkhan <attitude3cena.yf@gmail.com>
2026-01-26 08:57:56 -07:00
..
alerts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
channel Unify Is Read Only logic to avoid code repetition and improve redability (#8720) 2025-04-06 17:50:19 +02:00
deep_link Easy Login (#9261) 2025-11-20 12:38:06 +01:00
document Secure Files and preview PDF inline (#8844) 2025-06-19 15:30:56 +08:00
draft feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
emoji feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
file feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
gallery feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
general Channel banner display (#8735) 2025-04-08 11:15:18 +05:30
images Fix gallery image dimensions (#9247) 2025-11-10 19:18:27 +08:00
markdown Improve markdown code (#9164) 2025-11-04 10:05:56 +01:00
navigation Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
notification add unit tests to app/utils/notification (#8140) 2024-08-29 00:04:12 +08:00
permalink add unit tests to app/utils/permalink (#8141) 2024-08-29 00:03:25 +08:00
post Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
post_list Burn On Read Posts (#9307) 2025-12-11 09:42:16 +05:30
role Add utils/role unit tests (#8266) 2024-10-18 06:30:34 +08:00
scheduled_post Feature schedule posts (#8509) 2025-04-14 22:08:59 +05:30
search Add utils/search unit tests (#8267) 2024-10-18 06:29:49 +08:00
server feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
snack_bar Burn On Read Posts (#9307) 2025-12-11 09:42:16 +05:30
svg Gekidou MultiServers second part (#5963) 2022-02-17 10:42:06 -03:00
tap Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
theme Improve markdown code (#9164) 2025-11-04 10:05:56 +01:00
thread Better handle threads sync (#8641) 2025-03-19 09:23:22 +01:00
url Agents posts on mobile (#9317) 2025-12-09 03:56:12 -08:00
user Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
apps.test.ts fix issues found by sonarqube (#8095) 2024-07-18 09:40:47 +08:00
apps.ts Make attachments and app bindings more robust yet secure (#8570) 2025-03-14 12:02:32 +01:00
bor.test.ts Burn On Read Posts (#9307) 2025-12-11 09:42:16 +05:30
bor.ts Added BoR indicator in scheduled posts (#9355) 2026-01-12 20:09:24 +05:30
buttonStyles.test.ts Add Report a Problem functionality (#8605) 2025-04-24 11:12:55 +02:00
buttonStyles.ts Standardize tags and chips through the app (#8856) 2025-06-11 10:11:05 +02:00
categories.test.ts Add model mocks to TestHelper (#8715) 2025-03-28 09:40:08 +01:00
categories.ts Add unit tests to Utils buttonStyles and categories (#8015) 2024-06-14 17:11:36 +08:00
config.test.ts Add unit tests to utils config, datetime, error_handling, errors and files (#8018) 2024-06-15 01:29:03 +08:00
config.ts Fix race condition when the same websocket gets initialized twice (#7185) 2023-03-07 19:11:28 +01:00
custom_profile_attribute.ts [MM-62565] DB only custom profile attributes and fields (#8739) 2025-04-09 15:35:27 +02:00
datetime.test.ts Added BoR indicator in scheduled posts (#9355) 2026-01-12 20:09:24 +05:30
datetime.ts Added BoR indicator in scheduled posts (#9355) 2026-01-12 20:09:24 +05:30
dialog_conversion.test.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
dialog_conversion.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
dialog_utils.test.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
dialog_utils.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
error_handling.test.ts Add unit tests to utils config, datetime, error_handling, errors and files (#8018) 2024-06-15 01:29:03 +08:00
error_handling.ts Remove tand prevent double tap (#9078) 2025-08-25 12:03:01 +02:00
errors.test.ts [MM-62777] Fix errors being nested. Make MFA code more resilient to this situation (#8531) 2025-01-31 08:31:15 +02:00
errors.ts [MM-62777] Fix errors being nested. Make MFA code more resilient to this situation (#8531) 2025-01-31 08:31:15 +02:00
files.test.ts Secure Files and preview PDF inline (#8844) 2025-06-19 15:30:56 +08:00
files.tsx feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
font_family.test.ts Add Playbooks read-only support for mobile devices (#8978) 2025-07-14 09:21:37 +02:00
font_family.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
grapheme.test.ts New keyboard library Setup (#9278) 2026-01-13 22:38:35 +05:30
grapheme.ts New keyboard library Setup (#9278) 2026-01-13 22:38:35 +05:30
groups.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
groups.ts [Gekidou] Groups + group-memberships deferred fetch (#6370) 2022-07-07 12:20:06 +02:00
helpers.test.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
helpers.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
integrations.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
integrations.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
interactive_dialog_adapter.test.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
interactive_dialog_adapter.ts Add DialogRouter for Interactive Dialog to Apps Form migration (#9114) 2026-01-26 08:57:56 -07:00
intune_errors.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
key_mirror.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
key_mirror.ts MM-35115 [Gekidou] Login flow - Email and Password (#5402) 2021-06-18 00:57:40 -04:00
keyboard.ts New keyboard library Setup (#9278) 2026-01-13 22:38:35 +05:30
log.test.ts Add Report a Problem functionality (#8605) 2025-04-24 11:12:55 +02:00
log.ts Update dependencies (#8721) 2025-04-07 09:30:06 +08:00
mattermost_managed.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
mattermost_managed.ts Upgrade RN as well as update or replace other dependencies (#8011) 2024-06-19 09:33:45 +08:00
message_attachment.test.ts Make attachments and app bindings more robust yet secure (#8570) 2025-03-14 12:02:32 +01:00
message_attachment.ts Make attachments and app bindings more robust yet secure (#8570) 2025-03-14 12:02:32 +01:00
mix.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
mix.ts Remove watermelondb limitation on updating an already updated model (#7067) 2023-02-03 17:11:57 +02:00
opengraph.test.ts MM-59600 Add unit tests to utils/opengraph (#8444) 2025-01-06 15:30:48 -05:00
opengraph.ts MM-59600 Add unit tests to utils/opengraph (#8444) 2025-01-06 15:30:48 -05:00
permalink_sync.test.ts Ability to show attachment if the permalink post contains attachments. (#9101) 2025-09-12 13:44:54 +05:30
permalink_sync.ts Ability to show attachment if the permalink post contains attachments. (#9101) 2025-09-12 13:44:54 +05:30
push_proxy.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
push_proxy.ts capitalize back the alert text 2023-10-18 21:06:12 +02:00
reviews.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
reviews.ts Upgrade RN as well as update or replace other dependencies (#8011) 2024-06-19 09:33:45 +08:00
saml_challenge.ts Mobile-side for MM-65084 (#9115) 2025-09-29 14:29:37 -07:00
security.test.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
security.ts feat(iOS): Add Microsoft Intune MAM integration with multi-server support (#9312) 2025-12-10 13:07:28 +02:00
sentry.test.ts Update dependencies and upgrade to RN 0.76.5 (#8421) 2025-01-16 07:11:32 -07:00
sentry.ts Update dependencies and upgrade to RN 0.76.5 (#8421) 2025-01-16 07:11:32 -07:00
share_logs.test.ts Add Report a Problem functionality (#8605) 2025-04-24 11:12:55 +02:00
share_logs.ts Add Report a Problem functionality (#8605) 2025-04-24 11:12:55 +02:00
strings.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
strings.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
time.test.ts Feature schedule posts (#8509) 2025-04-14 22:08:59 +05:30
time.ts Feature schedule posts (#8509) 2025-04-14 22:08:59 +05:30
timezone.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
timezone.ts remove usages of isTimeZoneEnabled (#7769) 2024-01-30 13:22:55 +01:00
types.ts Add model mocks to TestHelper (#8715) 2025-03-28 09:40:08 +01:00
typography.test.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00
typography.ts added utils unit tests (#8040) 2024-07-05 07:17:09 +08:00