mattermost-mobile-upstream/detox/e2e/support/ui/screen/report_problem.ts
yasserfaraazkhan f36eff4fb4 detox: port E2E stabilization fixes from fix/cmt
Port the established flake-mitigation toolkit to detox-e2e-stabilization:
- setup.ts: Android APP_READY_TIMEOUT 60s->90s, MAX_LAUNCH_ATTEMPTS 2->3,
  adb reverse tcp:8081 pre-launch (slow-boot/hung-emulator mitigation)
- global_setup.js: post-login /api/v4/system/ping pre-warm (best-effort)
- channel.ts: postMessageAndVerify() cross-checks API + retries once on
  cold-POST -1005 drop
- modal_dismiss.ts: add leftover-screen close buttons + tutorial_highlight
  to KNOWN_MODAL_CLOSE_BUTTON_IDS (beforeEach recovery)
- archived_channel_navigation.ts: waitFor searchInput before replaceText
  (Android sheet-dismissal race) + re-submit search once (iOS index lag)
- search_messages.ts: corner-tap searchTab.open()
- manage_channel_members.ts: corner-tap userDisplayName
- report_problem.ts: tolerate external-browser fallback (unlicensed servers)
- agent_mention.e2e.ts: skip gracefully when mattermost-ai APIs 404/empty
- corner-taps {x:1,y:1} on bottom-sheet option rows (modal-hittability):
  pin_and_unpin_message, pinned_messages, search_messages, invite_people,
  channel_members manageButton
- file_preview_gallery: waitFor visibility before copy-public-link tap
  (footer renders after header; silent press drop fix)
2026-06-27 19:02:45 +05:30

78 lines
3.0 KiB
TypeScript

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import {SettingsScreen} from '@support/ui/screen';
import {isIos, tapNativeBackButton, timeouts} from '@support/utils';
class ReportProblemScreen {
testID = {
reportProblemScreen: 'report_problem.screen',
backButton: 'navigation.header.back',
enableLogAttachmentsToggleOff: 'report_problem.enable_log_attachments.toggled.false.button',
enableLogAttachmentsToggleOn: 'report_problem.enable_log_attachments.toggled.true.button',
};
reportProblemScreen = element(by.id(this.testID.reportProblemScreen));
// Native-stack back chevron via accessibility label.
get backButton(): Detox.NativeElement {
return isIos()
? element(by.label('Back')).atIndex(0)
: element(by.label('Navigate up')).atIndex(0);
}
enableLogAttachmentsToggleOff = element(by.id(this.testID.enableLogAttachmentsToggleOff));
enableLogAttachmentsToggleOn = element(by.id(this.testID.enableLogAttachmentsToggleOn));
toBeVisible = async () => {
await waitFor(this.reportProblemScreen).toBeVisible().withTimeout(timeouts.TEN_SEC);
return this.reportProblemScreen;
};
/**
* Opens the Report a Problem screen from Settings.
*
* On servers where the in-app screen is not available (unlicensed, or config
* not yet synced), tapping "Report a Problem" opens an external browser
* instead. This method detects that case, dismisses the browser, and returns
* false so callers can skip in-app assertions.
*
* @returns true if the in-app screen opened, false if an external browser opened
*/
open = async (): Promise<boolean> => {
await SettingsScreen.reportProblemOption.tap();
try {
await this.toBeVisible();
return true;
} catch {
// In-app screen didn't appear — external browser/email opened instead.
// Dismiss it so the app returns to Settings.
await tapNativeBackButton();
return false;
}
};
back = async () => {
// Native-stack back chevron.
await tapNativeBackButton();
await waitFor(this.reportProblemScreen).not.toBeVisible().withTimeout(timeouts.TEN_SEC);
};
enableAttachLogs = async () => {
await waitFor(this.enableLogAttachmentsToggleOff).toExist().withTimeout(timeouts.FOUR_SEC);
await this.enableLogAttachmentsToggleOff.tap();
await waitFor(this.enableLogAttachmentsToggleOn).toExist().withTimeout(timeouts.FOUR_SEC);
};
disableAttachLogs = async () => {
await waitFor(this.enableLogAttachmentsToggleOn).toExist().withTimeout(timeouts.FOUR_SEC);
await this.enableLogAttachmentsToggleOn.tap();
await waitFor(this.enableLogAttachmentsToggleOff).toExist().withTimeout(timeouts.FOUR_SEC);
};
}
const reportProblemScreen = new ReportProblemScreen();
export default reportProblemScreen;