fix(tours): long rides save, the horse route store stays bounded

A ride sends its full line with heights and every horse route section's
own line besides, about fifty bytes a point, so a ride along a few
thousand points of bridleway hit the API's 100kb body ceiling and the
save failed with a 413. Creating and editing a tour are now measured
against TOUR_WRITE_MAX_BYTES (2 MB), like the book and list file
routes; every other route, the tour copy among them, keeps 100kb.

The horse routes kept in memory are now bounded by section points as
well as by count (64 answers, 500k points), so panning a dense map can
no longer grow the server by hundreds of megabytes.

A search that found no connection can be asked again on the view whose
routes are shown, and a ride with a recorded time shows the horseshoe
beside its riding time instead of footprints.
This commit is contained in:
Maurice
2026-10-20 12:59:07 +02:00
parent 0331d9950f
commit 78366a9024
10 changed files with 182 additions and 25 deletions
+33 -1
View File
@@ -1,6 +1,6 @@
/**
* Miscellaneous integration tests.
* Covers MISC-001, 002, 004, 007, 008, 013, 015.
* Covers MISC-001, 002, 004, 007, 008, 009 to 014.
*/
import { buildApp } from '../../src/bootstrap';
import { db as testDb } from '../../src/db/database';
@@ -8,6 +8,7 @@ import { authCookie } from '../helpers/auth';
import { createUser } from '../helpers/factories';
import { resetTestDb, resetRateLimits } from '../helpers/test-db';
import type { INestApplication } from '@nestjs/common';
import { TOUR_WRITE_MAX_BYTES } from '@trek/shared';
import type { Application } from 'express';
import request from 'supertest';
@@ -158,4 +159,35 @@ describe('Request body ceiling', () => {
.send({ name: 'x'.repeat(200 * 1024) });
expect(elsewhere.status).toBe(413);
});
// A tour is sent whole on create and edit, its line and every fixed leg's
// line besides: a ride along a horse route passes 100kb (HOR-01). Only those
// two routes take the larger ceiling, and only up to TOUR_WRITE_MAX_BYTES.
it('MISC-013: a tour create or edit over 100kb reaches the router', async () => {
const created = await request(app)
.post('/api/trips/5/tours')
.set('Content-Type', 'application/json')
.send({ name: 'x'.repeat(300 * 1024) });
expect(created.status).not.toBe(413);
const edited = await request(app)
.put('/api/trips/5/tours/9')
.set('Content-Type', 'application/json')
.send({ name: 'x'.repeat(300 * 1024) });
expect(edited.status).not.toBe(413);
});
it('MISC-014: a tour past its own ceiling is refused, and the other tour routes keep 100kb', async () => {
const huge = await request(app)
.post('/api/trips/5/tours')
.set('Content-Type', 'application/json')
.send({ name: 'x'.repeat(TOUR_WRITE_MAX_BYTES + 1) });
expect(huge.status).toBe(413);
const copy = await request(app)
.post('/api/trips/5/tours/9/copy')
.set('Content-Type', 'application/json')
.send({ name: 'x'.repeat(200 * 1024) });
expect(copy.status).toBe(413);
});
});