ReviewOS

also looking at this

craft-native/craft

fix(ios): schedule a notification with the data the page gave it

#262
Merged glennmichael123 wants to merge fix/ios-notification-data into main
8 files +242 -22
scripts/mobile-e2e/ios.tsmodified+13-5
Changes to scripts/mobile-e2e/ios.ts
@@ -3,7 +3,7 @@ import type { LegOutcome, RunnerOptions } from './types'
33import { copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
44import { join } from 'node:path'
55import { bootSimulator, init, pickSimulator } from '../../packages/ios/src/index'
6import { deepLinkProblems, deepLinkResults, evaluateRun, hasTerminated, notificationBody, notificationPayload, notificationReceiptProblems, notificationReceiptReport, notificationTapProblems, notificationTapReport, ZIG_REFUSED_ACTIONS, ZIG_SERVED_ACTIONS, ZIG_TESTED_ACTIONS, zigDispatchedActions, zigHandBacks, zigRefusals } from './protocol'
6import { 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'
77import { command, driverPage, waitForFile } from './support'
88
99/** The scheme the probe registers, and the one its cold-start link uses. */
@@ -38,6 +38,9 @@ const CONFIG = {
3838 enableSpeechRecognition: false,
3939 // For the cold-start link (#198), which the harness opens from an XCUITest.
4040 enableDeepLinks: true,
41 // For the notification the page schedules with data (#258), served by
42 // Swift on the shim leg and by Zig on the runtime leg.
43 enableLocalNotifications: true,
4144 urlSchemes: [DEEP_LINK_SCHEME],
4245}
4346
@@ -68,8 +71,8 @@ const UI_TEST_CLASSES = ['DeepLinkColdStartTests', 'NotificationTapColdStartTest
6871
6972/**
7073 * How long the notification UI test gets in all. It starts a test runner,
71 * launches the app twice and answers a permission prompt; it usually takes
72 * under half a minute.
74 * launches the app four times, answers a permission prompt and waits out a
75 * scheduled notification; it usually takes about a minute.
7376 */
7477const NOTIFICATION_TEST_TIMEOUT_MS = 300_000
7578
@@ -340,6 +343,8 @@ schemes:
340343 TEST_RUNNER_PROBE_BUNDLE_ID: BUNDLE_ID,
341344 TEST_RUNNER_PROBE_NOTIFY_LINK: `${DEEP_LINK_SCHEME}://e2e/notify?run=${encodeURIComponent(nonce)}`,
342345 TEST_RUNNER_PROBE_PUSH_BODY: notificationBody(nonce, 'cold'),
346 TEST_RUNNER_PROBE_LOCAL_LINK: `${DEEP_LINK_SCHEME}://e2e/local?run=${encodeURIComponent(nonce)}`,
347 TEST_RUNNER_PROBE_LOCAL_BODY: notificationBody(nonce, 'local'),
343348 },
344349 stdin: 'ignore',
345350 stdout: Bun.file(notificationLog),
@@ -368,10 +373,13 @@ schemes:
368373 }
369374 else {
370375 failures.push(...notificationTapProblems(notificationTapReport(notificationOutput), nonce, notificationEvidence))
371 if (!pushed.includes('foreground'))
376 if (!pushed.includes('foreground')) {
372377 failures.push(`the notification UI test never got to the push that arrives while the app is open; see ${notificationEvidence}`)
373 else
378 }
379 else {
374380 failures.push(...notificationReceiptProblems(notificationReceiptReport(notificationOutput), nonce, notificationEvidence))
381 failures.push(...localNotificationProblems(notificationTapReport(notificationOutput, 'CRAFT-E2E-LOCAL-RESULT'), nonce, notificationEvidence))
382 }
375383 }
376384
377385 const dispatched = zigDispatchedActions(consoleText)