mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-20 19:16:08 +00:00
feat(native): a capability handshake between the app binary and the server's UI
The UI ships with the server and the binary through the stores, so the two drift. TrekShell.getCapabilities now reports the binary's shell API, version and native features by name (iOS and Android), and the UI turns each native feature on only where the binary has it; a binary from before the handshake counts as shell API 1 with none. The other way round, the server names the oldest binary its UI works with (minNativeShellApi), and an app below it is asked to update with a link to its store.
This commit is contained in:
@@ -4,6 +4,7 @@ import { SplashScreen } from '@capacitor/splash-screen';
|
||||
import { StatusBar, Style } from '@capacitor/status-bar';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { isEffectivelyOffline } from '../sync/networkMode';
|
||||
import { checkAppUpdate } from './capabilities';
|
||||
import { startNativeApp } from './nativeApp';
|
||||
import { keepOfflineShellFresh } from './offlineShell';
|
||||
import { isNativeApp, isNativeIos } from './platform';
|
||||
@@ -15,6 +16,7 @@ vi.mock('@capacitor/status-bar', () => ({ StatusBar: { setStyle: vi.fn() }, Styl
|
||||
vi.mock('./platform', () => ({ isNativeApp: vi.fn(), isNativeIos: vi.fn() }));
|
||||
vi.mock('./offlineShell', () => ({ keepOfflineShellFresh: vi.fn() }));
|
||||
vi.mock('../sync/networkMode', () => ({ isEffectivelyOffline: vi.fn() }));
|
||||
vi.mock('./capabilities', () => ({ checkAppUpdate: vi.fn(async () => false) }));
|
||||
|
||||
function backButtonHandler(): (event: { canGoBack: boolean }) => void {
|
||||
const call = vi.mocked(App.addListener).mock.calls.find(([name]) => name === 'backButton');
|
||||
@@ -44,6 +46,11 @@ describe('startNativeApp', () => {
|
||||
expect(StatusBar.setStyle).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('asks the binary what it can do and the server which binary it needs', () => {
|
||||
startNativeApp();
|
||||
expect(checkAppUpdate).toHaveBeenCalledWith(expect.any(Function));
|
||||
});
|
||||
|
||||
it('hides the splash after the first frame', () => {
|
||||
startNativeApp();
|
||||
vi.runOnlyPendingTimers();
|
||||
|
||||
Reference in New Issue
Block a user