fix(native): location at the accuracy asked for, and a Play payment that clears later is redeemed

- The location shim runs at high accuracy only while a watcher wants it and
  drops back once that watcher is gone, instead of keeping the 2 s GPS rate
  for the rest of the session.
- The purchase client can hand over a Play subscription that was paid but
  never delivered (a pending payment that cleared later), and the plans screen
  redeems it at once, as a restore would, before Google Play refunds it after
  three days.
This commit is contained in:
Maurice
2026-11-07 14:57:50 +01:00
parent c1c71a12cf
commit 46f4cab1b7
6 changed files with 120 additions and 7 deletions
+16
View File
@@ -55,6 +55,22 @@ describe('native geolocation', () => {
expect(TrekShell.stopLocation).toHaveBeenCalledTimes(1);
});
it('runs at high accuracy only while a watcher asks for it, and drops back after', () => {
installNativeGeolocation();
const passive = navigator.geolocation.watchPosition(vi.fn());
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: false });
const tracking = navigator.geolocation.watchPosition(vi.fn(), undefined, { enableHighAccuracy: true });
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: true });
navigator.geolocation.clearWatch(tracking);
expect(TrekShell.startLocation).toHaveBeenLastCalledWith({ highAccuracy: false });
expect(TrekShell.startLocation).toHaveBeenCalledTimes(3);
// A later passive watch does not inherit the high accuracy.
navigator.geolocation.watchPosition(vi.fn());
expect(TrekShell.startLocation).toHaveBeenCalledTimes(3);
navigator.geolocation.clearWatch(passive);
expect(TrekShell.stopLocation).not.toHaveBeenCalled();
});
it('settles a one-off request with the first fix, and passes a denial on as the Geolocation error', async () => {
installNativeGeolocation();
const once = vi.fn();