mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-22 21:11:14 +00:00
feat(native): the app needs TREK 5.1.4 on the server
nativeApi goes to 3 with 5.1.4, whose UI follows a widget or Live Activity tap that starts the app. The apps refuse an older server with the hint to update, and check a server they remember once more.
This commit is contained in:
@@ -3,7 +3,7 @@ import { candidateUrls, certificateTargetFor, probeDemo, probeServer, type Probe
|
||||
|
||||
const features = (
|
||||
url: string,
|
||||
data: unknown = { bookingImport: false, aiParsing: false, nativeApp: true, nativeApi: 2 }
|
||||
data: unknown = { bookingImport: false, aiParsing: false, nativeApp: true, nativeApi: 3 }
|
||||
): ProbeResponse => ({ status: 200, data, url });
|
||||
|
||||
describe('candidateUrls', () => {
|
||||
@@ -41,7 +41,7 @@ describe('certificateTargetFor', () => {
|
||||
|
||||
describe('probeServer', () => {
|
||||
it('accepts a server at the minimum native API version or above', async () => {
|
||||
for (const nativeApi of [2, 3]) {
|
||||
for (const nativeApi of [3, 4]) {
|
||||
const data = { bookingImport: false, nativeApp: true, nativeApi };
|
||||
const get = vi.fn().mockResolvedValue(features('https://trek.example.com/api/health/features', data));
|
||||
expect(await probeServer('https://trek.example.com', get)).toEqual({ ok: true, url: 'https://trek.example.com' });
|
||||
@@ -49,7 +49,7 @@ describe('probeServer', () => {
|
||||
});
|
||||
|
||||
it('calls a server below the minimum native API version too old', async () => {
|
||||
const data = { bookingImport: false, nativeApp: true, nativeApi: 1 };
|
||||
const data = { bookingImport: false, nativeApp: true, nativeApi: 2 };
|
||||
const get = vi.fn().mockResolvedValue(features('https://trek.example.com/api/health/features', data));
|
||||
expect(await probeServer('https://trek.example.com', get)).toEqual({ ok: false, reason: 'tooOld' });
|
||||
});
|
||||
@@ -196,7 +196,7 @@ describe('probeServer behind mutual TLS', () => {
|
||||
});
|
||||
|
||||
it('connects where the proxy asked and TREK answered, with or without a certificate', async () => {
|
||||
const trek = { bookingImport: false, nativeApp: true, nativeApi: 2 };
|
||||
const trek = { bookingImport: false, nativeApp: true, nativeApi: 3 };
|
||||
for (const sent of [true, false]) {
|
||||
const get = vi.fn().mockResolvedValue(asked(200, sent, trek));
|
||||
expect(await probeServer('https://trek.example.com', get)).toEqual({ ok: true, url: 'https://trek.example.com' });
|
||||
|
||||
@@ -43,12 +43,13 @@ const FEATURES_PATH = '/api/health/features';
|
||||
|
||||
/**
|
||||
* The oldest server API this app can work with (`nativeApi` in the features
|
||||
* response). 2 is TREK 5.1.3, the first server whose sign-in from the app does
|
||||
* not end in the browser. A server without the field is older still. Raising it
|
||||
* response). 3 is TREK 5.1.4, whose UI follows a widget or Live Activity tap
|
||||
* that starts the app; 2 was 5.1.3, the first server whose sign-in from the app
|
||||
* does not end in the browser. A server without the field is older still. Raising it
|
||||
* goes with SERVER_CHECK in TrekServerStore (iOS and Android), so a server the
|
||||
* app remembers from before is checked against the new minimum once.
|
||||
*/
|
||||
const MIN_NATIVE_API = 2;
|
||||
const MIN_NATIVE_API = 3;
|
||||
|
||||
function normalize(raw: string): string | null {
|
||||
let parsed: URL;
|
||||
|
||||
Reference in New Issue
Block a user