mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-19 09:58:15 +00:00
Closes manual release-test gaps for mobile (Detox + Maestro), automating new test cases and hardening flaky/CI-only failures uncovered along the way. ### New coverage automated - **MM-T416** offline/online post-retry (Android via airplane mode; iOS ultimately marked unsupported — see below) - **MM-T1194 / MM-T1193** custom ToS accept/decline survives relaunch - **MM-T3251** status change via account UI (cross-user visibility) - **MM-T510** channel-wide/keyword mention delivery — later expanded to a full 5-channel mention matrix with exact server-side counts - **MM-T3261 (_1/_2)** Report a Problem external hand-off (browser link mode, email mode) - **MM-T2940** iOS managed-config (MDM) pre-fill/autoconnect - **MM-T3271/3272** opening the app from a push notification (synthetic notification payloads, background/closed states) - Un-skipped several tests that turned out to already pass (stale skips) ### Root-caused failing tests - **Android SQLite corruption**: traced to native Kotlin DB connections not opening in WAL mode while JSI did (post #10109) — journal-mode mismatch corrupted the store on push-triggered writes. Fixed properly with a **WAL patch** (#10117) rather than the original destructive "wipe app database" workaround, which was reverted. - **Fabric crash** (`addViewAt`/reparent) on `SlideUpPanelItem` taps — root-caused to view flattening racing sheet mounts; fixed with `collapsable={false}` (went through a revert/re-revert once CI reproduced the crash without it). - **Search race**: stale in-flight search results could overwrite a cleared search box — fixed with request-id tagging. - **iOS offline detection**: multiple iterations (AAAA sampling → Cloudflare-prefix check → final decision) landed on refusing iOS offline simulation outright, since all E2E servers are Cloudflare-fronted/anycast and the address space can't be enumerated/blocked. - **MM-T3261 config patch** intermittently silently ignored by the server — root-caused to `ReportAProblemType` being environment-managed on PR Spinwicks (config PATCH returns 200 but is silently dropped); now detected and reported as a skip with proven cause, not a failure. - **MM-T416 failed-post timing**: multiple rounds of tightening the wait bound to match the client's actual retry/backoff/timeout ceiling (ended at ~150s, derived from OkHttp/retry-interceptor math, not guessed). - **MM-T5603 upload wait**: raised to match the client's real 180s upload timeout. - **Classification banner suite**: fixed to verify config state directly instead of trusting a PATCH reply that the cloud sometimes drops. ### CI/reporting infra fixes - Dedicated Maestro steps (MM-T3261, MM-T67856_4) weren't feeding into the merged JUnit report and couldn't gate pass/fail — fixed report merging/naming so they now count. - Android Maestro logcat capture added (previously iOS-only diagnostics). - Jest retry logic no longer discards passing results from a shard killed by timeout. - Sharding raised 24→28. - Removed dead Detox Pilot/Playbooks scaffolding (unused, uncovered by CI). ### Cleanup - Comment/docs pass stripping narrative session-archaeology from long explanatory comments, keeping only load-bearing facts and CI references.
81 lines
3.6 KiB
TypeScript
81 lines
3.6 KiB
TypeScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
/**
|
|
* EMM managed-configuration control for the iOS simulator.
|
|
*
|
|
* `@mattermost/react-native-emm` reads the MDM payload from
|
|
* `UserDefaults.standard["com.apple.configuration.managed"]` — the same key an MDM
|
|
* (Intune, Jamf, ...) writes on an enrolled device. On a simulator that dictionary can be
|
|
* seeded with `simctl spawn <udid> defaults write <bundle id> ...`, which exercises the
|
|
* app's config-enforcement layer (pre-filled server and username, allowOtherServers
|
|
* autoconnect) without enrollment. Enrollment itself, app wrapping, and per-device
|
|
* policies (copy/paste protection, blur, PIN) are out of reach here and stay manual.
|
|
*
|
|
* Android is refused: `RestrictionsManager` restrictions can only be set by a device or
|
|
* profile owner (a DPC such as Test DPC), which the CI emulator does not carry.
|
|
*/
|
|
import {execFileSync} from 'child_process';
|
|
|
|
import {device} from 'detox';
|
|
|
|
import {logDebug} from '../../../provision/log';
|
|
|
|
const MANAGED_CONFIG_KEY = 'com.apple.configuration.managed';
|
|
|
|
// Keys from the app's ManagedConfig (types/global/managed_config.d.ts); MDM payloads are
|
|
// string-valued, so booleans are the strings 'true' / 'false'.
|
|
export type ManagedConfigInput = Partial<Record<
|
|
'allowOtherServers' | 'blurApplicationScreen' | 'copyAndPasteProtection' | 'inAppPinCode' |
|
|
'inAppSessionAuth' | 'jailbreakProtection' | 'serverName' | 'serverUrl' | 'timeout' |
|
|
'timeoutVPN' | 'username' | 'useVPN' | 'vendor',
|
|
string
|
|
>>;
|
|
|
|
// The Detox iOS app id. `.detoxrc.json` only carries the binary path; Maestro's
|
|
// MAESTRO_APP_ID is the same value.
|
|
const IOS_BUNDLE_ID = process.env.MM_E2E_IOS_BUNDLE_ID || 'com.mattermost.rnbeta';
|
|
|
|
const simctlDefaults = (args: string[]): string => {
|
|
return execFileSync('xcrun', ['simctl', 'spawn', device.id, 'defaults', ...args], {stdio: 'pipe'}).toString();
|
|
};
|
|
|
|
/** Whether this platform can have a managed configuration injected (iOS simulator only). */
|
|
export const isManagedConfigControlAvailable = (): boolean => {
|
|
if (device.getPlatform() === 'ios') {
|
|
return true;
|
|
}
|
|
logDebug('[managed_config] Android managed configuration unavailable: app restrictions need a device/profile owner (DPC), which the emulator does not have');
|
|
return false;
|
|
};
|
|
|
|
/**
|
|
* Write the managed configuration the app will read on its next launch. Call with the
|
|
* app terminated: `react-native-emm` also listens for UserDefaults changes, but a cold
|
|
* launch is the only path that is deterministic on every screen.
|
|
*/
|
|
export const setIosManagedConfig = (config: ManagedConfigInput): void => {
|
|
const pairs = Object.entries(config).flatMap(([key, value]) => (value === undefined ? [] : [key, String(value)]));
|
|
simctlDefaults(['write', IOS_BUNDLE_ID, MANAGED_CONFIG_KEY, '-dict', ...pairs]);
|
|
logDebug(`[managed_config] wrote ${Object.keys(config).length} managed keys for ${IOS_BUNDLE_ID}`);
|
|
};
|
|
|
|
/** Remove the managed configuration. Safe when none was written. */
|
|
export const clearIosManagedConfig = (): void => {
|
|
try {
|
|
simctlDefaults(['delete', IOS_BUNDLE_ID, MANAGED_CONFIG_KEY]);
|
|
logDebug(`[managed_config] cleared managed configuration for ${IOS_BUNDLE_ID}`);
|
|
} catch {
|
|
// `defaults delete` fails when the key is absent — nothing to clear.
|
|
}
|
|
};
|
|
|
|
/** Read back what the app will see, for assertions and failure messages. */
|
|
export const readIosManagedConfig = (): string => {
|
|
try {
|
|
return simctlDefaults(['read', IOS_BUNDLE_ID, MANAGED_CONFIG_KEY]).trim();
|
|
} catch {
|
|
return '';
|
|
}
|
|
};
|