feat(mobile): share history as Markdown or original audio and harden the E2E gate
Adds history share (Markdown file / original audio) with 12-locale strings, pins Maestro to the target device with --udid, allows cleartext only for explicit local E2E artifacts, and fixes small-screen scroll/keyboard races in the Maestro flows. Evidence: docs/evidence/2026-11-17-backlog-operations.md.
This commit is contained in:
parent
e0b1ceaa75
commit
8d8aaf5794
29 changed files with 627 additions and 26 deletions
|
|
@ -9,9 +9,22 @@ param(
|
|||
)
|
||||
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($PSVersionTable.PSEdition -eq 'Desktop') {
|
||||
Import-Module (Join-Path $env:SystemRoot 'system32\WindowsPowerShell\v1.0\Modules\Microsoft.PowerShell.Utility\Microsoft.PowerShell.Utility.psd1') -Force
|
||||
}
|
||||
$root = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
|
||||
$androidRoot = Join-Path $root 'apps\mobile-rn\android'
|
||||
$status = & supabase status --workdir (Join-Path $root 'server') -o env 2>$null
|
||||
$previousErrorActionPreference = $ErrorActionPreference
|
||||
try {
|
||||
$ErrorActionPreference = 'Continue'
|
||||
$status = & npx --yes supabase@3.2.0 status --workdir (Join-Path $root 'server') -o env 2>$null
|
||||
$statusExitCode = $LASTEXITCODE
|
||||
} finally {
|
||||
$ErrorActionPreference = $previousErrorActionPreference
|
||||
}
|
||||
if ($statusExitCode -ne 0) {
|
||||
throw "Supabase status failed with exit code $statusExitCode"
|
||||
}
|
||||
$configuration = @{}
|
||||
foreach ($line in $status) {
|
||||
if ($line -match '^([A-Z_]+)="(.*)"$') { $configuration[$matches[1]] = $matches[2] }
|
||||
|
|
|
|||
|
|
@ -28,6 +28,8 @@ if [[ "$connected_devices" -ne 1 && -z "${ANDROID_SERIAL:-}" ]]; then
|
|||
exit 2
|
||||
fi
|
||||
adb get-state | grep -Fx 'device' >/dev/null
|
||||
target_serial="${ANDROID_SERIAL:-$(adb get-serialno)}"
|
||||
maestro_device_args=(--udid "$target_serial")
|
||||
|
||||
collect_evidence() {
|
||||
local gate_status="$1"
|
||||
|
|
@ -72,7 +74,7 @@ adb shell pm path "$PACKAGE_NAME" | grep -F "package:" >/dev/null
|
|||
run_flow() {
|
||||
local flow_name="$1"
|
||||
local flow_path="$2"
|
||||
"$MAESTRO_BIN" test "$flow_path" \
|
||||
"$MAESTRO_BIN" test "${maestro_device_args[@]}" "$flow_path" \
|
||||
--format JUNIT \
|
||||
--output "apps/mobile-rn/.maestro/${flow_name}.junit.xml" \
|
||||
--test-output-dir "$OUTPUT_ROOT/$flow_name"
|
||||
|
|
@ -89,7 +91,7 @@ adb shell wm size reset >/dev/null
|
|||
display_override_active='false'
|
||||
|
||||
if [[ -n "${MOBILE_E2E_EMAIL:-}" && -n "${MOBILE_E2E_PASSWORD:-}" ]]; then
|
||||
"$MAESTRO_BIN" test 'apps/mobile-rn/.maestro/authenticated-parity.yaml' \
|
||||
"$MAESTRO_BIN" test "${maestro_device_args[@]}" 'apps/mobile-rn/.maestro/authenticated-parity.yaml' \
|
||||
-e MOBILE_E2E_EMAIL="$MOBILE_E2E_EMAIL" \
|
||||
-e MOBILE_E2E_PASSWORD="$MOBILE_E2E_PASSWORD" \
|
||||
--format JUNIT \
|
||||
|
|
|
|||
|
|
@ -86,6 +86,7 @@ function sameFileSnapshot(left, right) {
|
|||
function parseArguments(argv) {
|
||||
const allowed = new Set([
|
||||
'aab',
|
||||
'allow-local-cleartext',
|
||||
'apk',
|
||||
'bundletool',
|
||||
'expected-admob-app-id',
|
||||
|
|
@ -706,7 +707,7 @@ function verifyDeepLinkManifest(manifest) {
|
|||
if (!verifiedAppLink) fail('missing_verified_app_link_accept_invite')
|
||||
}
|
||||
|
||||
function verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId) {
|
||||
function verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId, allowLocalCleartext = false) {
|
||||
const packageInfo = badging.match(/package: name='([^']+)' versionCode='([0-9]+)' versionName='([^']+)'/)
|
||||
if (!packageInfo || packageInfo[1] !== EXPECTED_PACKAGE) fail('package_name_mismatch')
|
||||
const versionCode = Number(packageInfo[2])
|
||||
|
|
@ -719,7 +720,8 @@ function verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId) {
|
|||
if (mode !== 'debug' && debuggable) fail(`${mode}_must_not_be_debuggable`)
|
||||
if (mode === 'debug' && !debuggable) fail('debug_must_be_debuggable')
|
||||
|
||||
if (!/android:usesCleartextTraffic[^\n]*0x0\b/.test(manifest) && mode !== 'debug') {
|
||||
const cleartextAllowed = mode === 'debug' || (mode === 'e2e' && allowLocalCleartext)
|
||||
if (!/android:usesCleartextTraffic[^\n]*0x0\b/.test(manifest) && !cleartextAllowed) {
|
||||
fail(`${mode}_cleartext_must_be_false`)
|
||||
}
|
||||
const requiredPermissions = [
|
||||
|
|
@ -747,11 +749,11 @@ function verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId) {
|
|||
return { debuggable, adMobAppId, versionName, versionCode, minSdk, targetSdk }
|
||||
}
|
||||
|
||||
function verifyManifest(aapt, archive, mode, expectedAdMobAppId) {
|
||||
function verifyManifest(aapt, archive, mode, expectedAdMobAppId, allowLocalCleartext = false) {
|
||||
const apkPath = archive.absolute
|
||||
const badging = runArtifact(aapt, ['dump', 'badging', apkPath], 'aapt_badging', archive)
|
||||
const manifest = runArtifact(aapt, ['dump', 'xmltree', apkPath, 'AndroidManifest.xml'], 'aapt_manifest', archive)
|
||||
return verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId)
|
||||
return verifyManifestContracts(badging, manifest, mode, expectedAdMobAppId, allowLocalCleartext)
|
||||
}
|
||||
|
||||
function verifyArchive(archive, mode) {
|
||||
|
|
@ -1114,6 +1116,35 @@ function runSigningPolicySelfTest() {
|
|||
if (!legacyArgumentRejected) fail('self_test_legacy_certificate_argument_not_rejected')
|
||||
|
||||
const manifestFixture = createManifestContractSelfTestFixture()
|
||||
const localOptions = parseArguments([
|
||||
'--mode', 'e2e',
|
||||
'--apk', 'local.apk',
|
||||
'--allow-local-cleartext', 'true',
|
||||
])
|
||||
if (localOptions['allow-local-cleartext'] !== 'true') fail('self_test_local_cleartext_option')
|
||||
const localE2eManifest = manifestFixture.manifest
|
||||
.replace('android:usesCleartextTraffic=(type 0x12)0x0', 'android:usesCleartextTraffic=(type 0x12)0xffffffff')
|
||||
.replaceAll('ca-app-pub-1234567890123456~1234567890', TEST_ADMOB_APP_ID)
|
||||
expectSelfTestFailure(
|
||||
'manifest_local_e2e_cleartext_default',
|
||||
() => verifyManifestContracts(manifestFixture.badging, localE2eManifest, 'e2e', null),
|
||||
'e2e_cleartext_must_be_false',
|
||||
)
|
||||
verifyManifestContracts(manifestFixture.badging, localE2eManifest, 'e2e', null, true)
|
||||
expectSelfTestFailure(
|
||||
'manifest_release_cleartext_override',
|
||||
() => verifyManifestContracts(
|
||||
manifestFixture.badging,
|
||||
manifestFixture.manifest.replace(
|
||||
'android:usesCleartextTraffic=(type 0x12)0x0',
|
||||
'android:usesCleartextTraffic=(type 0x12)0xffffffff',
|
||||
),
|
||||
'release',
|
||||
'ca-app-pub-1234567890123456~1234567890',
|
||||
true,
|
||||
),
|
||||
'release_cleartext_must_be_false',
|
||||
)
|
||||
const manifestEvidence = verifyManifestContracts(
|
||||
manifestFixture.badging,
|
||||
manifestFixture.manifest,
|
||||
|
|
@ -1434,6 +1465,11 @@ if (cliArguments.length === 1 && cliArguments[0] === '--self-test') {
|
|||
const options = parseArguments(cliArguments)
|
||||
const mode = options.mode
|
||||
if (!VALID_MODES.has(mode)) fail(`unknown_mode_${mode}`)
|
||||
const localCleartextOption = options['allow-local-cleartext']
|
||||
if (localCleartextOption !== undefined && (localCleartextOption !== 'true' || mode !== 'e2e')) {
|
||||
fail('allow_local_cleartext_only_valid_for_local_e2e')
|
||||
}
|
||||
const allowLocalCleartext = localCleartextOption === 'true'
|
||||
if (!options.apk) fail('apk_path_required')
|
||||
const apkPath = resolve(options.apk)
|
||||
if (!existsSync(apkPath)) fail(`apk_missing_${apkPath}`)
|
||||
|
|
@ -1462,6 +1498,7 @@ try {
|
|||
archive,
|
||||
mode,
|
||||
options['expected-admob-app-id'],
|
||||
allowLocalCleartext,
|
||||
)
|
||||
if (mode !== 'debug') {
|
||||
const expectedVersionName = options['expected-version-name']
|
||||
|
|
|
|||
|
|
@ -4,6 +4,10 @@ import { resolve } from 'node:path'
|
|||
const ROOT = resolve(import.meta.dirname, '../..')
|
||||
const BUILD_GRADLE = resolve(ROOT, 'apps/mobile-rn/android/app/build.gradle')
|
||||
const ROOT_BUILD_GRADLE = resolve(ROOT, 'apps/mobile-rn/android/build.gradle')
|
||||
const ANDROID_MANIFEST = resolve(ROOT, 'apps/mobile-rn/android/app/src/main/AndroidManifest.xml')
|
||||
const IOS_PROJECT = resolve(ROOT, 'apps/mobile-rn/ios/D3ROVoice.xcodeproj/project.pbxproj')
|
||||
const IOS_PLIST = resolve(ROOT, 'apps/mobile-rn/ios/D3ROVoice/Info.plist')
|
||||
const AUTH_REDIRECT = resolve(ROOT, 'apps/mobile-rn/src/lib/auth-redirect.ts')
|
||||
const PRODUCT_VERSION = resolve(ROOT, 'release/product-version.json')
|
||||
const CONFIG_MODULE = resolve(
|
||||
ROOT,
|
||||
|
|
@ -60,16 +64,48 @@ function parseIntegerConstant(source, name) {
|
|||
}
|
||||
|
||||
async function readSourceContractFiles() {
|
||||
const [gradle, rootGradle, configModule, productVersionSource] = await Promise.all([
|
||||
const [
|
||||
gradle,
|
||||
rootGradle,
|
||||
configModule,
|
||||
productVersionSource,
|
||||
androidManifest,
|
||||
iosProject,
|
||||
iosPlist,
|
||||
authRedirect,
|
||||
] = await Promise.all([
|
||||
readFile(BUILD_GRADLE, 'utf8'),
|
||||
readFile(ROOT_BUILD_GRADLE, 'utf8'),
|
||||
readFile(CONFIG_MODULE, 'utf8'),
|
||||
readFile(PRODUCT_VERSION, 'utf8'),
|
||||
readFile(ANDROID_MANIFEST, 'utf8'),
|
||||
readFile(IOS_PROJECT, 'utf8'),
|
||||
readFile(IOS_PLIST, 'utf8'),
|
||||
readFile(AUTH_REDIRECT, 'utf8'),
|
||||
])
|
||||
return { gradle, rootGradle, configModule, productVersion: JSON.parse(productVersionSource) }
|
||||
return {
|
||||
gradle,
|
||||
rootGradle,
|
||||
configModule,
|
||||
productVersion: JSON.parse(productVersionSource),
|
||||
androidManifest,
|
||||
iosProject,
|
||||
iosPlist,
|
||||
authRedirect,
|
||||
}
|
||||
}
|
||||
|
||||
function verifySourceContractSources({ gradle, rootGradle, configModule, productVersion }) {
|
||||
function verifySourceContractSources(sources) {
|
||||
const {
|
||||
gradle,
|
||||
rootGradle,
|
||||
configModule,
|
||||
productVersion,
|
||||
androidManifest,
|
||||
iosProject,
|
||||
iosPlist,
|
||||
authRedirect,
|
||||
} = sources
|
||||
if (/gradle\.startParameter\.taskNames/.test(gradle)) {
|
||||
fail('variant_gate_must_not_use_requested_task_name_heuristics')
|
||||
}
|
||||
|
|
@ -78,6 +114,36 @@ function verifySourceContractSources({ gradle, rootGradle, configModule, product
|
|||
}
|
||||
|
||||
const defaultConfigBlock = extractBlock(gradle, /\bdefaultConfig\s*\{/, 'missing_default_config')
|
||||
requireMatch(
|
||||
defaultConfigBlock,
|
||||
/applicationId\s+"com\.d3ro\.voice"/,
|
||||
'android_application_id_must_be_canonical',
|
||||
)
|
||||
const iosBundleIds = [...iosProject.matchAll(/PRODUCT_BUNDLE_IDENTIFIER\s*=\s*([^;]+);/g)]
|
||||
.map(match => match[1].trim())
|
||||
if (iosBundleIds.length === 0 || iosBundleIds.some(value => value !== 'com.d3ro.voice')) {
|
||||
fail('ios_bundle_identifier_must_be_canonical')
|
||||
}
|
||||
const iosSchemeBlock = iosPlist.match(
|
||||
/<key>CFBundleURLSchemes<\/key>\s*<array>([\s\S]*?)<\/array>/,
|
||||
)?.[1]
|
||||
if (!iosSchemeBlock) fail('ios_url_schemes_missing')
|
||||
const iosSchemes = [...iosSchemeBlock.matchAll(/<string>([^<]+)<\/string>/g)].map(match => match[1])
|
||||
if (iosSchemes.length !== 1 || iosSchemes[0] !== 'd3ro-voice') {
|
||||
fail('ios_url_scheme_must_be_canonical')
|
||||
}
|
||||
requireMatch(
|
||||
authRedirect,
|
||||
/AUTH_REDIRECT_URL\s*=\s*'d3ro-voice:\/\/auth-callback'/,
|
||||
'oauth_callback_scheme_must_be_canonical',
|
||||
)
|
||||
for (const host of ['auth-callback', 'accept-invite']) {
|
||||
requireMatch(
|
||||
androidManifest,
|
||||
new RegExp(`android:scheme="d3ro-voice"\\s+android:host="${host}"`),
|
||||
`android_${host}_deep_link_must_be_canonical`,
|
||||
)
|
||||
}
|
||||
const buildTypesBlock = extractBlock(gradle, /\bbuildTypes\s*\{/, 'missing_build_types')
|
||||
const e2eBlock = extractBlock(buildTypesBlock, /\be2e\s*\{/, 'missing_e2e_build_type')
|
||||
const debugBlock = extractBlock(buildTypesBlock, /\bdebug\s*\{/, 'missing_debug_build_type')
|
||||
|
|
@ -269,10 +335,10 @@ async function verifySourceContract() {
|
|||
verifySourceContractSources(await readSourceContractFiles())
|
||||
}
|
||||
|
||||
function expectSourceContractFailure(sources, mutate, expectedMessage) {
|
||||
function expectSourceContractFailure(sources, mutate, expectedMessage, field = 'gradle') {
|
||||
let failedAsExpected = false
|
||||
try {
|
||||
verifySourceContractSources({ ...sources, gradle: mutate(sources.gradle) })
|
||||
verifySourceContractSources({ ...sources, [field]: mutate(sources[field]) })
|
||||
} catch (error) {
|
||||
if (!(error instanceof Error) || !error.message.includes(expectedMessage)) throw error
|
||||
failedAsExpected = true
|
||||
|
|
@ -341,6 +407,35 @@ function verifyVariant(variant, buildConfig) {
|
|||
if (process.argv.includes('--self-test')) {
|
||||
const sources = await readSourceContractFiles()
|
||||
verifySourceContractSources(sources)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(gradle) => gradle.replace('applicationId "com.d3ro.voice"', 'applicationId "invalid.example"'),
|
||||
'android_application_id_must_be_canonical',
|
||||
)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(iosProject) => iosProject.replaceAll('PRODUCT_BUNDLE_IDENTIFIER = com.d3ro.voice;', 'PRODUCT_BUNDLE_IDENTIFIER = invalid.example;'),
|
||||
'ios_bundle_identifier_must_be_canonical',
|
||||
'iosProject',
|
||||
)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(iosPlist) => iosPlist.replace('<string>d3ro-voice</string>', '<string>d3ro</string>'),
|
||||
'ios_url_scheme_must_be_canonical',
|
||||
'iosPlist',
|
||||
)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(authRedirect) => authRedirect.replace('d3ro-voice://auth-callback', 'd3ro://auth-callback'),
|
||||
'oauth_callback_scheme_must_be_canonical',
|
||||
'authRedirect',
|
||||
)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(androidManifest) => androidManifest.replace('android:scheme="d3ro-voice" android:host="auth-callback"', 'android:scheme="d3ro" android:host="auth-callback"'),
|
||||
'android_auth-callback_deep_link_must_be_canonical',
|
||||
'androidManifest',
|
||||
)
|
||||
expectSourceContractFailure(
|
||||
sources,
|
||||
(gradle) => gradle.replace('candidate.name == "preE2eBuild"', 'candidate.name == "preE2eBuildDisabled"'),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue