mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-12-02 09:22:15 +00:00
feat(native): the Android app's widgets, location, tile store, Play Billing and Google Wallet
The UI now turns these on by feature on Android as well as iOS: - widgets, widgetTrips and the travel day (liveActivity) write the same snapshot to the Android app's Glance widgets; the travel day also sends the next stop's minutes and the stops' colours for the Live Update. - geolocation answers navigator.geolocation from the app's location stream. - tileCache: Android keeps Mapbox's resources in its WebView client, so the map is offline-capable there too, without the iOS trek-tile:// rewrite. - playBilling: the purchase client buys through Google Play on Android, with the purchase token as the receipt the control plane verifies. - googleWallet: a booking's button adds it to Google Wallet on Android, through the save link the server asks the TREK services for.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { hasNativeFeature } from './capabilities';
|
||||
import { _resetNativeGeolocation, installNativeGeolocation } from './geolocation';
|
||||
import { isNativeIos } from './platform';
|
||||
import { isNativeApp } from './platform';
|
||||
import { TrekShell, type NativeLocationPayload } from './trekShell';
|
||||
|
||||
vi.mock('./platform', () => ({ isNativeIos: vi.fn() }));
|
||||
vi.mock('./platform', () => ({ isNativeApp: vi.fn() }));
|
||||
vi.mock('./capabilities', () => ({ hasNativeFeature: vi.fn() }));
|
||||
vi.mock('./trekShell', () => ({
|
||||
TrekShell: { startLocation: vi.fn(), stopLocation: vi.fn(), addListener: vi.fn() },
|
||||
@@ -16,7 +16,7 @@ const original = navigator.geolocation;
|
||||
beforeEach(() => {
|
||||
_resetNativeGeolocation();
|
||||
Object.defineProperty(navigator, 'geolocation', { configurable: true, value: original });
|
||||
vi.mocked(isNativeIos).mockReturnValue(true);
|
||||
vi.mocked(isNativeApp).mockReturnValue(true);
|
||||
vi.mocked(hasNativeFeature).mockReturnValue(true);
|
||||
vi.mocked(TrekShell.startLocation).mockReset().mockResolvedValue();
|
||||
vi.mocked(TrekShell.stopLocation).mockReset().mockResolvedValue();
|
||||
@@ -71,9 +71,13 @@ describe('native geolocation', () => {
|
||||
expect(failed.mock.calls[0][0]).toMatchObject({ code: 1, PERMISSION_DENIED: 1 });
|
||||
});
|
||||
|
||||
it('leaves the browser API alone outside an iOS binary with the feature', () => {
|
||||
it('leaves the browser API alone outside an app binary with the feature', () => {
|
||||
vi.mocked(hasNativeFeature).mockReturnValue(false);
|
||||
expect(installNativeGeolocation()).toBe(false);
|
||||
expect(navigator.geolocation).toBe(original);
|
||||
vi.mocked(hasNativeFeature).mockReturnValue(true);
|
||||
vi.mocked(isNativeApp).mockReturnValue(false);
|
||||
expect(installNativeGeolocation()).toBe(false);
|
||||
expect(navigator.geolocation).toBe(original);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user