also looking at this
test(ios): verify app termination before local notification delivery
#308
5 files
+96
-21
| @@ -512,8 +512,9 @@ | ||
| 512 | 512 | // arrival is not a tap. |
| 513 | 513 | // |
| 514 | 514 | // #258: opened by the local link, the page schedules a notification of |
| 515 | // its own, with data, a few seconds out. The test kills the app before it | |
| 516 | // fires and taps it, and this same report says what the tap carried. | |
| 515 | // its own, with data, far enough out for the UI test to stop the app. | |
| 516 | // The test kills it before it fires and taps it, and this same report | |
| 517 | // says what the tap carried. | |
| 517 | 518 | // |
| 518 | 519 | // Permission is asked for only when the link asks, because nothing |
| 519 | 520 | // answers the prompt on the launches simctl makes. iOS only: Android has |
| @@ -527,12 +528,20 @@ | ||
| 527 | 528 | } |
| 528 | 529 | if (launch && launch.url.indexOf('://e2e/local') !== -1) { |
| 529 | 530 | var scheduled = function (text) { document.getElementById('notification-local').textContent = 'CRAFT-E2E-LOCAL-SCHEDULED ' + text } |
| 531 | var delay = Number(new URL(launch.url).searchParams.get('delayMs')) | |
| 532 | if (!Number.isInteger(delay) || delay < 60000 || delay > 180000) { | |
| 533 | scheduled('rejected invalid scheduling window') | |
| 534 | return | |
| 535 | } | |
| 536 | // Record the earliest delivery time before crossing the bridge. A | |
| 537 | // slow completion must not invent a later deadline for the UI test. | |
| 538 | var fireAt = Date.now() + delay | |
| 530 | 539 | window.craft.notifications.schedule({ |
| 531 | 540 | title: 'Craft E2E', |
| 532 | 541 | body: NONCE + ' local', |
| 533 | delay: 8000, | |
| 542 | delay: delay, | |
| 534 | 543 | data: { craftE2E: NONCE, stage: 'local', nested: { kept: true } } |
| 535 | }).then(function () { scheduled('ok') }, function (error) { scheduled('rejected ' + describeError(error).message) }) | |
| 544 | }).then(function () { scheduled('ok ' + fireAt) }, function (error) { scheduled('rejected ' + describeError(error).message) }) | |
| 536 | 545 | } |
| 537 | 546 | var onTap = window.craft.notifications && window.craft.notifications.onTap |
| 538 | 547 | var seen = { dispatched: 0, taps: [], onTap: typeof onTap, unsubscribe: null } |