Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(ci): today's changes pass the release gates

Maurice742edc4a7922
diff --git a/client/ios/App/App/TrekBridgeViewController.swift b/client/ios/App/App/TrekBridgeViewController.swift
index 9a9e9218e..a7f44e124 100644
--- a/client/ios/App/App/TrekBridgeViewController.swift
+++ b/client/ios/App/App/TrekBridgeViewController.swift
@@ -41,6 +41,7 @@ class TrekBridgeViewController: CAPBridgeViewController {
// reachable" with a server that was there all along.
if let webView, let inner = webView.navigationDelegate {
let proxy = TrekNavigationProxy(inner: inner)
+ proxy.onErrorPage = { [weak self] error in self?.errorPageChanged(error) }
navigationProxy = proxy
webView.navigationDelegate = proxy
}
@@ -711,6 +712,8 @@ final class TrekNavigationProxy: NSObject, WKNavigationDelegate {
private let inner: WKNavigationDelegate
/// A page of the server has shown since launch; from then on no sign-in host is learned (TrekSignInRedirect).
private var serverShown = false
+ /// Told on the main thread whether the main frame now shows an error page in place of the server's.
+ var onErrorPage: ((Bool) -> Void)?
init(inner: WKNavigationDelegate) {
self.inner = inner
@@ -808,7 +811,7 @@ final class TrekNavigationProxy: NSObject, WKNavigationDelegate {
}
if navigationResponse.isForMainFrame, let http = navigationResponse.response as? HTTPURLResponse {
let error = http.statusCode >= 400 && http.statusCode < 500
- DispatchQueue.main.async { [weak self] in self?.errorPageChanged(error) }
+ DispatchQueue.main.async { [weak self] in self?.onErrorPage?(error) }
}
let selector = NSSelectorFromString("webView:decidePolicyForNavigationResponse:decisionHandler:")
guard (inner as AnyObject).responds(to: selector) else {
diff --git a/client/scripts/strict-baseline.json b/client/scripts/strict-baseline.json
index c3779b289..a138fdcf7 100644
--- a/client/scripts/strict-baseline.json
+++ b/client/scripts/strict-baseline.json
@@ -42,7 +42,6 @@
"src/components/Map/MapViewGL.tsx": 1,
"src/components/Map/ReservationOverlay.test.tsx": 1,
"src/components/Map/transitGeometry.ts": 1,
- "src/components/Map/useDawarichTrailGL.test.ts": 4,
"src/components/Map/useMarkerThumbs.ts": 1,
"src/components/PDF/TripPDF.tsx": 40,
"src/components/Packing/PackingListPanelItemRow.test.tsx": 2,
diff --git a/client/src/components/Map/useDawarichTrailGL.test.ts b/client/src/components/Map/useDawarichTrailGL.test.ts
index 62c654d34..658d804c4 100644
--- a/client/src/components/Map/useDawarichTrailGL.test.ts
+++ b/client/src/components/Map/useDawarichTrailGL.test.ts
@@ -180,19 +180,23 @@ describe('useDawarichTrailGL', () => {
expect(gl.spies.addSource).toHaveBeenCalledWith(SOURCE, expect.objectContaining({ type: 'geojson' }))
const [casingCall, lineCall] = gl.spies.addLayer.mock.calls
- expect(casingCall[0].id).toBe(CASING_LAYER)
- expect(casingCall[0].paint['line-color']).toBe(DAWARICH_TRAIL_CASING)
- expect(casingCall[0].paint['line-width']).toBe(7)
- expect(casingCall[0].paint['line-opacity']).toBe(0.9)
- expect(lineCall[0].id).toBe(LINE_LAYER)
+ if (!casingCall || !lineCall) throw new Error('expected the casing and the line layer')
+ type LayerSpec = { id: string; paint: Record<string, unknown> }
+ const casing = casingCall[0] as LayerSpec
+ const line = lineCall[0] as LayerSpec
+ expect(casing.id).toBe(CASING_LAYER)
+ expect(casing.paint['line-color']).toBe(DAWARICH_TRAIL_CASING)
+ expect(casing.paint['line-width']).toBe(7)
+ expect(casing.paint['line-opacity']).toBe(0.9)
+ expect(line.id).toBe(LINE_LAYER)
// Per-feature colour, with the casing white as the fallback a feature
// without one falls back to. The GPX layer uses the same shape.
- expect(lineCall[0].paint['line-color']).toEqual(['coalesce', ['get', 'color'], DAWARICH_TRAIL_CASING])
+ expect(line.paint['line-color']).toEqual(['coalesce', ['get', 'color'], DAWARICH_TRAIL_CASING])
// Dashed, so the recording is distinguishable from the planned route for
// someone who cannot tell the two hues apart.
- expect(lineCall[0].paint['line-dasharray']).toEqual([2.5, 1.25])
- expect(lineCall[0].paint['line-width']).toBe(4)
- expect(lineCall[0].paint['line-opacity']).toBe(1)
+ expect(line.paint['line-dasharray']).toEqual([2.5, 1.25])
+ expect(line.paint['line-width']).toBe(4)
+ expect(line.paint['line-opacity']).toBe(1)
// Both go beneath the planned route's casing. The line is inserted second
// and therefore ends up above its own casing and still below the plan.
diff --git a/client/src/native/keyboardFields.test.ts b/client/src/native/keyboardFields.test.ts
index 2bac3d8ba..ba6f77789 100644
--- a/client/src/native/keyboardFields.test.ts
+++ b/client/src/native/keyboardFields.test.ts
@@ -1,5 +1,5 @@
import { afterEach, describe, expect, it, vi } from 'vitest';
-import { closeOnDone, prepareField, prepareKeyboardFields } from './keyboardFields';
+import { prepareField, prepareKeyboardFields } from './keyboardFields';
function field(html: string): HTMLInputElement {
document.body.innerHTML = html;
@@ -91,40 +91,46 @@ describe('prepareKeyboardFields', () => {
});
describe('closeOnDone', () => {
- const enter = (el: HTMLElement) => el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true }));
+ // Wired the way the app wires it: on the document, in the capture phase,
+ // ahead of every handler the field has of its own.
+ const enter = (el: HTMLElement) =>
+ el.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }));
+ let stop: () => void = () => {};
+ afterEach(() => {
+ stop();
+ vi.useRealTimers();
+ });
it('closes the keyboard when nothing took the Enter of a "done" field', () => {
vi.useFakeTimers();
+ stop = prepareKeyboardFields(document);
const el = field('<input name="title" enterkeyhint="done">');
el.focus();
- el.addEventListener('keydown', closeOnDone);
enter(el);
vi.runAllTimers();
expect(document.activeElement).not.toBe(el);
- vi.useRealTimers();
});
it('keeps the keyboard for a field that acted on the Enter and cleared itself', () => {
vi.useFakeTimers();
+ stop = prepareKeyboardFields(document);
const el = field('<input name="item" enterkeyhint="done">');
el.value = 'Socks';
el.focus();
el.addEventListener('keydown', () => {
el.value = '';
});
- el.addEventListener('keydown', closeOnDone);
enter(el);
vi.runAllTimers();
expect(document.activeElement).toBe(el);
- vi.useRealTimers();
});
it('leaves "go" and "search" fields and handled Enters alone', () => {
vi.useFakeTimers();
+ stop = prepareKeyboardFields(document);
for (const hint of ['go', 'search']) {
const el = field(`<input enterkeyhint="${hint}">`);
el.focus();
- el.addEventListener('keydown', closeOnDone);
enter(el);
vi.runAllTimers();
expect(document.activeElement).toBe(el);
@@ -132,10 +138,8 @@ describe('closeOnDone', () => {
const handled = field('<input enterkeyhint="done">');
handled.focus();
handled.addEventListener('keydown', (e) => e.preventDefault());
- handled.addEventListener('keydown', closeOnDone);
- handled.dispatchEvent(new KeyboardEvent('keydown', { key: 'Enter', bubbles: true, cancelable: true }));
+ enter(handled);
vi.runAllTimers();
expect(document.activeElement).toBe(handled);
- vi.useRealTimers();
});
});
diff --git a/client/src/native/keyboardFields.ts b/client/src/native/keyboardFields.ts
index aa8f04ce0..e9c028f2d 100644
--- a/client/src/native/keyboardFields.ts
+++ b/client/src/native/keyboardFields.ts
@@ -110,14 +110,19 @@ export function prepareField(target: EventTarget | null): void {
}
}
-/** Enter on a "done" field that nothing acted on closes the keyboard. */
+/**
+ * Enter on a "done" field that nothing acted on closes the keyboard. Listens in
+ * the capture phase, so the field's text is read before any handler of the field
+ * runs; whether one took the Enter is read off the event once it has gone round.
+ */
export function closeOnDone(e: KeyboardEvent): void {
const el = e.target;
- if (e.key !== 'Enter' || e.isComposing || e.defaultPrevented) return;
+ if (e.key !== 'Enter' || e.isComposing) return;
if (!(el instanceof HTMLInputElement) || el.getAttribute('enterkeyhint') !== 'done') return;
const before = el.value;
// After every handler of this Enter, including ones React schedules.
setTimeout(() => {
+ if (e.defaultPrevented) return;
if (el.ownerDocument.activeElement === el && el.value === before) el.blur();
}, 0);
}
@@ -128,11 +133,11 @@ export function prepareKeyboardFields(doc: Document = document): () => void {
const onFocus = (e: FocusEvent) => prepareField(e.target);
doc.addEventListener('touchstart', onTouch, { capture: true, passive: true });
doc.addEventListener('focusin', onFocus, true);
- // Bubbling, so a field's own handler runs first and can take the Enter.
- doc.addEventListener('keydown', closeOnDone);
+ // Capturing, so the text is read before the field's own handler can change it.
+ doc.addEventListener('keydown', closeOnDone, true);
return () => {
doc.removeEventListener('touchstart', onTouch, { capture: true });
doc.removeEventListener('focusin', onFocus, true);
- doc.removeEventListener('keydown', closeOnDone);
+ doc.removeEventListener('keydown', closeOnDone, true);
};
}
diff --git a/server/src/db/migrations/Migration20200101046380_ireland_gained_its_counties.ts b/server/src/db/migrations/Migration20200101046380_ireland_gained_its_counties.ts
index 50f52ab91..ff1b3a5a3 100644
--- a/server/src/db/migrations/Migration20200101046380_ireland_gained_its_counties.ts
+++ b/server/src/db/migrations/Migration20200101046380_ireland_gained_its_counties.ts
@@ -72,13 +72,14 @@ export class Migration20200101046380_ireland_gained_its_counties extends Migrati
override async up(): Promise<void> {
await this.execute(`DELETE FROM place_regions WHERE UPPER(COALESCE(country_code, '')) = 'IE'`);
+ // Queued in order, run after the reads below: the codes come from the table
+ // above and the row ids from the database, nothing a user typed.
for (const [code, , province] of COUNTIES) {
- await this.execute(
+ this.addSql(
`INSERT INTO hidden_regions (user_id, region_code, country_code)
- SELECT h.user_id, ?, h.country_code FROM hidden_regions h
- WHERE h.region_code = ? AND UPPER(h.country_code) = 'IE'
- AND NOT EXISTS (SELECT 1 FROM hidden_regions x WHERE x.user_id = h.user_id AND x.region_code = ?)`,
- [code, province, code],
+ SELECT h.user_id, '${code}', h.country_code FROM hidden_regions h
+ WHERE h.region_code = '${province}' AND UPPER(h.country_code) = 'IE'
+ AND NOT EXISTS (SELECT 1 FROM hidden_regions x WHERE x.user_id = h.user_id AND x.region_code = '${code}')`,
);
}
@@ -95,14 +96,14 @@ export class Migration20200101046380_ireland_gained_its_counties extends Migrati
const county = counties.get(countyKey(row.region_name || ''));
if (!county) continue;
const target = `${row.user_id}|${county.code}`;
+ const id = Number(row.id);
+ if (!Number.isInteger(id)) continue;
if (held.has(target)) {
- await this.execute(`DELETE FROM visited_regions WHERE id = ?`, [row.id]);
+ this.addSql(`DELETE FROM visited_regions WHERE id = ${id}`);
} else {
- await this.execute(`UPDATE visited_regions SET region_code = ?, region_name = ? WHERE id = ?`, [
- county.code,
- county.name,
- row.id,
- ]);
+ this.addSql(
+ `UPDATE visited_regions SET region_code = '${county.code}', region_name = '${county.name}' WHERE id = ${id}`,
+ );
held.add(target);
}
}
diff --git a/server/tests/unit/nest/ai-connections/provider-adapters.test.ts b/server/tests/unit/nest/ai-connections/provider-adapters.test.ts
index f9ea47354..f0d2f9103 100644
--- a/server/tests/unit/nest/ai-connections/provider-adapters.test.ts
+++ b/server/tests/unit/nest/ai-connections/provider-adapters.test.ts
@@ -719,13 +719,15 @@ describe('OpenAiChatClient', () => {
it('OACH-011: any other server, refusal or request keeps the body as it was and is not asked again (#3043)', async () => {
// Ollama, LM Studio, vLLM and OpenRouter never see the parameter.
- for (const kind of ['custom', 'openrouter', 'openai', 'gemini'] as const) {
- const plain = fetchAnswering(streamResponse(STREAM));
- await run(
- new OpenAiChatClient(kind, 'm', 'http://ollama:11434/v1', null, plain.fetcher).stream(REQUEST, signal()),
- );
- expect(plain.body()).not.toHaveProperty('reasoning_effort');
- }
+ await Promise.all(
+ (['custom', 'openrouter', 'openai', 'gemini'] as const).map(async (kind) => {
+ const plain = fetchAnswering(streamResponse(STREAM));
+ await run(
+ new OpenAiChatClient(kind, 'm', 'http://ollama:11434/v1', null, plain.fetcher).stream(REQUEST, signal()),
+ );
+ expect(plain.body()).not.toHaveProperty('reasoning_effort');
+ }),
+ );
const once = async (request: AiChatRequest, ...responses: Response[]) => {
const http = fetchAnswering(...responses);
diff --git a/server/tests/unit/nest/collab.service.test.ts b/server/tests/unit/nest/collab.service.test.ts
index f0105be87..9bd5e57e1 100644
--- a/server/tests/unit/nest/collab.service.test.ts
+++ b/server/tests/unit/nest/collab.service.test.ts
@@ -344,7 +344,7 @@ describe('listMessages', () => {
expect(msgs[0].text).toBe('');
expect(msgs[0].deleted).toBe(1);
// Gone from the row itself, not only blanked on the way out.
- const row = await findRow(orm, CollabMessages, { id: r.message!.id });
+ const row = await findRow(orm, CollabMessages, { id: msgs[0].id });
expect(row?.text).toBe('');
});
diff --git a/server/tests/unit/nest/precompressed-static.test.ts b/server/tests/unit/nest/precompressed-static.test.ts
index 61a09ddd1..79f4dd3a8 100644
--- a/server/tests/unit/nest/precompressed-static.test.ts
+++ b/server/tests/unit/nest/precompressed-static.test.ts
@@ -20,6 +20,9 @@ describe('precompressedStatic', () => {
writeFileSync(path.join(assets, 'nested', 'Map-AbCd1234.css'), STYLE);
writeFileSync(path.join(assets, 'nested', 'Map-AbCd1234.css.br'), brotliCompressSync(STYLE));
writeFileSync(path.join(assets, 'plain-AbCd1234.js'), SCRIPT);
+ const WASM = Buffer.alloc(4096, 7);
+ writeFileSync(path.join(assets, 'engine-AbCd1234.wasm'), WASM);
+ writeFileSync(path.join(assets, 'engine-AbCd1234.wasm.br'), brotliCompressSync(WASM));
writeFileSync(path.join(root, 'secret.js'), SCRIPT);
writeFileSync(path.join(root, 'secret.js.br'), brotliCompressSync(SCRIPT));
afterAll(() => rmSync(root, { recursive: true, force: true }));
@@ -100,6 +103,14 @@ describe('precompressedStatic', () => {
expect(climbing.headers['content-encoding']).toBeUndefined();
});
+ it('PRECOMP-008: a copy of a type without a charset is typed as the original, with no charset', async () => {
+ const res = await get('/assets/engine-AbCd1234.wasm', 'br');
+
+ expect(res.status).toBe(200);
+ expect(res.headers['content-encoding']).toBe('br');
+ expect(res.headers['content-type']).toBe('application/wasm');
+ });
+
it('PRECOMP-007: a build without copies is served as before', async () => {
const bare = express();
bare.use(precompressedStatic(path.join(root, 'missing')));
diff --git a/shared/src/i18n/en/native.ts b/shared/src/i18n/en/native.ts
index f02d148ba..5fe0497b9 100644
--- a/shared/src/i18n/en/native.ts
+++ b/shared/src/i18n/en/native.ts
@@ -93,7 +93,7 @@ const native: TranslationStrings = {
'native.plans.restoreNoneAndroid': 'No active subscription found on this Google account.',
'native.claim.agree':
'By subscribing, the TREK Cloud terms apply to providing your instance (provider: Maurice Bötger, Rostock). The store handles the purchase, payment and refunds.',
- 'native.claim.consentTitle': 'How TREK Cloud differs from a self-hosted TREK (German, legally binding):',
+ 'native.claim.consentTitle': 'How TREK Cloud differs from TREK on your own server (German, legally binding):',
'native.claim.consentLoading': 'Loading the agreement…',
'native.claim.consentUnavailable': 'The agreement could not be loaded. Check your connection and try again.',
'native.claim.consentRequired': 'Please read and confirm the agreement first.',