mirror of
https://github.com/mattermost/mattermost-mobile.git
synced 2026-11-22 19:38:17 +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.
121 lines
4.8 KiB
JavaScript
121 lines
4.8 KiB
JavaScript
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
// CI util unit tests: run with `node --test detox/utils/maestro_report.test.js`.
|
|
|
|
const assert = require('node:assert/strict');
|
|
const fs = require('node:fs');
|
|
const os = require('node:os');
|
|
const path = require('node:path');
|
|
const {afterEach, beforeEach, describe, it} = require('node:test');
|
|
|
|
const {writeMaestroJestJsonForTsio, compareMaestroJunitFilenames} = require('./maestro_report');
|
|
|
|
describe('writeMaestroJestJsonForTsio', () => {
|
|
let tmpDir;
|
|
|
|
beforeEach(() => {
|
|
tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), 'maestro-jest-tsio-'));
|
|
});
|
|
|
|
afterEach(() => {
|
|
fs.rmSync(tmpDir, {recursive: true, force: true});
|
|
});
|
|
|
|
function writeXml(contents) {
|
|
const xmlPath = path.join(tmpDir, 'maestro-report.xml');
|
|
fs.writeFileSync(xmlPath, contents);
|
|
return xmlPath;
|
|
}
|
|
|
|
it('returns false without writing when input is missing or empty', () => {
|
|
const missingOut = path.join(tmpDir, 'missing.json');
|
|
assert.equal(writeMaestroJestJsonForTsio(path.join(tmpDir, 'nope.xml'), missingOut), false);
|
|
assert.equal(fs.existsSync(missingOut), false);
|
|
|
|
const emptyXml = writeXml(`<?xml version="1.0"?>
|
|
<testsuites>
|
|
<testsuite name="s" tests="0" failures="0" errors="0" skipped="0" time="0"/>
|
|
</testsuites>`);
|
|
const emptyOut = path.join(tmpDir, 'empty.json');
|
|
assert.equal(writeMaestroJestJsonForTsio(emptyXml, emptyOut), false);
|
|
assert.equal(fs.existsSync(emptyOut), false);
|
|
});
|
|
|
|
it('maps Maestro passed/skipped/failed to Jest passed/pending/failed', () => {
|
|
const xmlPath = writeXml(`<?xml version="1.0"?>
|
|
<testsuites>
|
|
<testsuite name="s" tests="3" failures="1" errors="0" skipped="1" time="3">
|
|
<testcase name="login" classname="auth" file="detox/maestro/flows/account/login.yml" time="1.5"/>
|
|
<testcase name="skip_me" classname="auth" file="detox/maestro/flows/account/skip.yml" time="0.1">
|
|
<skipped/>
|
|
</testcase>
|
|
<testcase name="broken" classname="channels" file="detox/maestro/flows/channels/broken.yml" time="1.2">
|
|
<failure message="boom">boom</failure>
|
|
</testcase>
|
|
</testsuite>
|
|
</testsuites>`);
|
|
const outPath = path.join(tmpDir, 'out.json');
|
|
assert.equal(writeMaestroJestJsonForTsio(xmlPath, outPath), true);
|
|
|
|
const payload = JSON.parse(fs.readFileSync(outPath, 'utf8'));
|
|
const byTitle = Object.fromEntries(
|
|
payload.testResults.flatMap((suite) => suite.assertionResults.map((ar) => [ar.title, ar.status])),
|
|
);
|
|
assert.deepEqual(byTitle, {
|
|
login: 'passed',
|
|
skip_me: 'pending',
|
|
broken: 'failed',
|
|
});
|
|
assert.equal(payload.numPassedTests, 1);
|
|
assert.equal(payload.numPendingTests, 1);
|
|
assert.equal(payload.numFailedTests, 1);
|
|
assert.equal(payload.numTotalTests, 3);
|
|
assert.equal(payload.success, false);
|
|
assert.ok(payload.snapshot);
|
|
assert.equal(payload.snapshot.total, 0);
|
|
assert.equal(payload.wasInterrupted, false);
|
|
});
|
|
|
|
it('groups assertions by file/classname key', () => {
|
|
const xmlPath = writeXml(`<?xml version="1.0"?>
|
|
<testsuites>
|
|
<testsuite name="s" tests="2" failures="0" errors="0" skipped="0" time="2">
|
|
<testcase name="one" classname="auth" file="detox/maestro/flows/account/login.yml" time="1"/>
|
|
<testcase name="two" classname="auth" file="detox/maestro/flows/account/login.yml" time="1"/>
|
|
</testsuite>
|
|
</testsuites>`);
|
|
const outPath = path.join(tmpDir, 'grouped.json');
|
|
assert.equal(writeMaestroJestJsonForTsio(xmlPath, outPath), true);
|
|
|
|
const payload = JSON.parse(fs.readFileSync(outPath, 'utf8'));
|
|
assert.equal(payload.numTotalTestSuites, 1);
|
|
assert.equal(payload.testResults.length, 1);
|
|
assert.equal(payload.testResults[0].name, 'detox/maestro/flows/account/login.yml');
|
|
assert.deepEqual(
|
|
payload.testResults[0].assertionResults.map((ar) => ar.title),
|
|
['one', 'two'],
|
|
);
|
|
assert.equal(payload.success, true);
|
|
assert.equal(payload.numPassedTests, 2);
|
|
assert.equal(payload.numFailedTests, 0);
|
|
});
|
|
});
|
|
|
|
describe('compareMaestroJunitFilenames', () => {
|
|
it('should order batch files numerically and report files deterministically', () => {
|
|
const files = [
|
|
'maestro-report-T3261_2.xml',
|
|
'maestro-batch-10.xml',
|
|
'maestro-batch-2.xml',
|
|
'maestro-report-T67856_4.xml',
|
|
];
|
|
assert.deepEqual([...files].sort(compareMaestroJunitFilenames), [
|
|
'maestro-batch-2.xml',
|
|
'maestro-batch-10.xml',
|
|
'maestro-report-T3261_2.xml',
|
|
'maestro-report-T67856_4.xml',
|
|
]);
|
|
});
|
|
});
|