also looking at this
test(ios): verify app termination before local notification delivery
#308
5 files
+96
-21
| @@ -3,7 +3,7 @@ import type { LegOutcome, RunnerOptions } from './types' | ||
| 3 | 3 | import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs' |
| 4 | 4 | import { join } from 'node:path' |
| 5 | 5 | import { bootSimulator, init, pickSimulator } from '../../packages/ios/src/index' |
| 6 | import { deepLinkProblems, deepLinkResults, evaluateRun, hasTerminated, localNotificationProblems, notificationBody, notificationPayload, notificationReceiptProblems, notificationReceiptReport, notificationTapProblems, notificationTapReport, ZIG_REFUSED_ACTIONS, ZIG_SERVED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigHandBacks, zigRefusals } from './protocol' | |
| 6 | import { deepLinkProblems, deepLinkResults, evaluateRun, hasTerminated, LOCAL_NOTIFICATION_DELAY_MS, localNotificationProblems, NOTIFICATION_TEST_TIMEOUT_MS, notificationBody, notificationPayload, notificationReceiptProblems, notificationReceiptReport, notificationTapProblems, notificationTapReport, ZIG_REFUSED_ACTIONS, ZIG_SERVED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigHandBacks, zigRefusals } from './protocol' | |
| 7 | 7 | import { command, driverPage, waitForFile } from './support' |
| 8 | 8 | |
| 9 | 9 | /** The scheme the probe registers, and the one its cold-start link uses. */ |
| @@ -69,13 +69,6 @@ const UI_TESTS = `${APP_NAME}UITests` | ||
| 69 | 69 | /** The UI test classes, each run on its own with `-only-testing`. */ |
| 70 | 70 | const UI_TEST_CLASSES = ['DeepLinkColdStartTests', 'NotificationTapColdStartTests'] as const |
| 71 | 71 | |
| 72 | /** | |
| 73 | * How long the notification UI test gets in all. It starts a test runner, | |
| 74 | * launches the app four times, answers a permission prompt and waits out a | |
| 75 | * scheduled notification; it usually takes about a minute. | |
| 76 | */ | |
| 77 | const NOTIFICATION_TEST_TIMEOUT_MS = 300_000 | |
| 78 | ||
| 79 | 72 | /** |
| 80 | 73 | * The pushes the notification UI test has asked for, in order, one per |
| 81 | 74 | * `CRAFT-E2E-PUSH-READY <stage>` line. |
| @@ -343,7 +336,7 @@ schemes: | ||
| 343 | 336 | TEST_RUNNER_PROBE_BUNDLE_ID: BUNDLE_ID, |
| 344 | 337 | TEST_RUNNER_PROBE_NOTIFY_LINK: `${DEEP_LINK_SCHEME}://e2e/notify?run=${encodeURIComponent(nonce)}`, |
| 345 | 338 | TEST_RUNNER_PROBE_PUSH_BODY: notificationBody(nonce, 'cold'), |
| 346 | TEST_RUNNER_PROBE_LOCAL_LINK: `${DEEP_LINK_SCHEME}://e2e/local?run=${encodeURIComponent(nonce)}`, | |
| 339 | TEST_RUNNER_PROBE_LOCAL_LINK: `${DEEP_LINK_SCHEME}://e2e/local?run=${encodeURIComponent(nonce)}&delayMs=${LOCAL_NOTIFICATION_DELAY_MS}`, | |
| 347 | 340 | TEST_RUNNER_PROBE_LOCAL_BODY: notificationBody(nonce, 'local'), |
| 348 | 341 | }, |
| 349 | 342 | stdin: 'ignore', |
| @@ -365,6 +358,8 @@ schemes: | ||
| 365 | 358 | } |
| 366 | 359 | if (tapping.exitCode === null) tapping.kill() |
| 367 | 360 | await tapping.exited |
| 361 | if (tapping.exitCode !== 0) | |
| 362 | failures.push(`notification UI test exited ${tapping.exitCode}; see ${notificationEvidence}`) | |
| 368 | 363 | await command(['xcrun', 'simctl', 'io', device.udid, 'screenshot', join(evidence, 'notification-screen.png')], { allowFailure: true }) |
| 369 | 364 | await command(['xcrun', 'simctl', 'terminate', device.udid, BUNDLE_ID], { allowFailure: true }) |
| 370 | 365 | const notificationOutput = readFileSync(notificationLog, 'utf8') |