also looking at this
fix(ios): ask again when Core Location has no fix yet, rather than failing the caller
#264
3 files
+120
-7
| @@ -407,6 +407,27 @@ describe('Craft iOS builder', () => { | ||
| 407 | 407 | expect(body.indexOf('content.userInfo = info')).toBeLessThan(body.indexOf('UNNotificationRequest(identifier: id, content: content')) |
| 408 | 408 | }) |
| 409 | 409 | |
| 410 | it('asks again when Core Location has no fix yet, rather than failing the caller', async () => { | |
| 411 | // #260: kCLErrorLocationUnknown rejected a getCurrentPosition whose fix | |
| 412 | // was seconds away. requestLocation gives up on it, so the one-shot asks | |
| 413 | // again while the same caller waits; its timeout still bounds the wait. | |
| 414 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-location-no-fix-')) | |
| 415 | await init({ name: 'WildLoop', bundleId: 'org.wildloop.app', output, config: { enableGeolocation: true } }) | |
| 416 | const swift = readFileSync(join(output, 'Sources', 'WildLoopApp.swift'), 'utf8') | |
| 417 | ||
| 418 | const failed = swift.slice(swift.indexOf('didFailWithError error: Error) {')) | |
| 419 | const body = failed.slice(0, failed.indexOf('\n }\n')) | |
| 420 | const noFixYet = body.indexOf('nativeError.code == CLError.Code.locationUnknown.rawValue') | |
| 421 | expect(noFixYet).toBeGreaterThan(-1) | |
| 422 | // Decided before anything settles the caller or tells the page. | |
| 423 | expect(noFixYet).toBeLessThan(body.indexOf('finishSingleLocationRequest()')) | |
| 424 | expect(noFixYet).toBeLessThan(body.indexOf('rejectCallback(')) | |
| 425 | expect(noFixYet).toBeLessThan(body.indexOf('sendToWeb("craftLocationError"')) | |
| 426 | // Asks again only for the caller that was told to wait. | |
| 427 | expect(body).toContain('guard let self, self.singleLocationCallbackId == waiting else { return }') | |
| 428 | expect(body).toContain('self.locationManager?.requestLocation()') | |
| 429 | }) | |
| 430 | ||
| 410 | 431 | it('settles calendar callbacks only after a real EventKit operation', async () => { |
| 411 | 432 | const output = mkdtempSync(join(tmpdir(), 'craft-ios-calendar-')) |
| 412 | 433 | await init({ |