also looking at this
test(mobile-e2e): prove iOS location settles, and that Zig served it
#213
6 files
+157
-28
| @@ -166,18 +166,43 @@ | ||
| 166 | 166 | } |
| 167 | 167 | }, |
| 168 | 168 | { |
| 169 | // The failure path. Geolocation is off in the harness config, so the | |
| 170 | // native side must answer — with a code that names the configuration — | |
| 171 | // rather than leave the promise pending. A dropped callback here is | |
| 172 | // indistinguishable from a slow one to the page, which is exactly why | |
| 173 | // the case asserts the rejection and not merely "did not resolve". | |
| 174 | name: 'geolocation.disabled.rejects', | |
| 169 | // The second half of #197: asking for location permission the app | |
| 170 | // already holds used to wait for an authorization change that never | |
| 171 | // comes, because nothing changes. The harness grants it with | |
| 172 | // `simctl privacy` before launch, so both calls must answer at once. | |
| 173 | name: 'permissions.location.granted', | |
| 175 | 174 | platforms: ['ios'], |
| 176 | 175 | run: function () { |
| 177 | return withTimeout(function () { return window.craft.getCurrentPosition() }).then(function (outcome) { | |
| 178 | if (outcome.state === 'timeout') return 'getCurrentPosition never settled' | |
| 179 | if (outcome.state === 'resolved') return 'getCurrentPosition resolved on a disabled capability' | |
| 180 | if (outcome.error.code !== 'CAPABILITY_DISABLED') return 'code is ' + JSON.stringify(outcome.error.code) | |
| 176 | return withTimeout(function () { return window.craft.permissions.check('location') }).then(function (checked) { | |
| 177 | if (checked.state !== 'resolved') return 'permissions.check ' + checked.state + ' ' + (checked.error ? checked.error.message : '') | |
| 178 | if (checked.value !== 'granted') return 'permissions.check answered ' + JSON.stringify(checked.value) | |
| 179 | return withTimeout(function () { return window.craft.permissions.request('location') }).then(function (requested) { | |
| 180 | if (requested.state === 'timeout') return 'permissions.request never settled for a permission already granted' | |
| 181 | if (requested.state !== 'resolved') return 'permissions.request rejected: ' + requested.error.message | |
| 182 | if (requested.value !== 'granted') return 'permissions.request answered ' + JSON.stringify(requested.value) | |
| 183 | }) | |
| 184 | }) | |
| 185 | } | |
| 186 | }, | |
| 187 | { | |
| 188 | // #197 as reported: high accuracy, no cached fix, a fifteen-second | |
| 189 | // timeout, on a simulator with an explicit coordinate. It never | |
| 190 | // settled. The harness sets the coordinate with `simctl location` | |
| 191 | // and compares it with what the page reports, so a position the | |
| 192 | // bridge invented would not match. | |
| 193 | name: 'geolocation.currentPosition', | |
| 194 | platforms: ['ios'], | |
| 195 | run: function () { | |
| 196 | var options = { enableHighAccuracy: true, maximumAge: 0, timeout: 15000 } | |
| 197 | return withTimeout(function () { return window.craft.location.getCurrentPosition(options) }, 20000).then(function (outcome) { | |
| 198 | if (outcome.state === 'timeout') return 'getCurrentPosition never settled, not even by its own 15s timeout' | |
| 199 | if (outcome.state === 'rejected') | |
| 200 | return 'getCurrentPosition rejected: ' + outcome.error.code + ' ' + outcome.error.message | |
| 201 | if (!outcome.value) return 'getCurrentPosition resolved with nothing' | |
| 202 | emit({ event: 'observed', name: 'latitude', value: outcome.value.latitude }) | |
| 203 | emit({ event: 'observed', name: 'longitude', value: outcome.value.longitude }) | |
| 204 | if (typeof outcome.value.latitude !== 'number' || typeof outcome.value.longitude !== 'number') | |
| 205 | return 'position is ' + JSON.stringify(outcome.value) | |
| 181 | 206 | }) |
| 182 | 207 | } |
| 183 | 208 | }, |