Files
Maurice 724c88c201 style: format server and shared with prettier
A mechanical prettier --write over server/src, server/tests, server/scripts
and shared/src with the workspaces' .prettierrc; nothing but layout and
import order changes, and every file keeps the same set of imports. shared
is formatted throughout and its format baseline is empty. The server
baseline keeps the 35 files that Prettier would grow past their lint:size
limit (they need a split first, which is not a formatting change), and the
generated entity files stay as their generator writes them.
2026-10-10 21:23:37 +02:00

60 lines
2.0 KiB
TypeScript

import { buildApp } from '../../src/bootstrap';
import type { INestApplication } from '@nestjs/common';
import request from 'supertest';
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
/**
* A book is bigger than a form post (#1973).
*
* The API's body ceiling is a hundred kilobytes, which is right for an
* interface of forms and ids and wrong for a photo book. A Studio document is
* sent WHOLE on every autosave, on purpose, and a fortnight's journey passes a
* hundred kilobytes before anybody asks for road geometry: an Iceland book with
* roads measured 101KB against a 100KB limit.
*
* What that produced was not an error anybody could act on. The save failed
* with a 413, the editor said "not saved", and nothing anywhere said why —
* which is the same shape of bug as the mood mark that could not be stored, and
* it deserves the same kind of guard.
*/
describe('the size of a book', () => {
let app: INestApplication;
beforeAll(async () => {
app = await buildApp();
await app.init();
});
afterAll(async () => {
await app?.close();
});
/** A body far past the ordinary ceiling, shaped like a save. */
const bigBody = () => ({
title: 'A long journey',
baseVersion: 1,
document: { version: 1, title: 'A long journey', spreads: [], filler: 'x'.repeat(400_000) },
});
it('takes a document larger than the API-wide limit rather than refusing it', async () => {
const res = await request(app.getHttpServer()).put('/api/journeys/1/book').send(bigBody());
/*
* Unauthenticated, so 401 is the expected answer and the point of the test
* is what it is NOT: a 413 means the body never reached the router, which
* is exactly the failure being guarded against.
*/
expect(res.status).not.toBe(413);
});
it('keeps the tighter limit on every other route', async () => {
const res = await request(app.getHttpServer())
.post('/api/journeys')
.send({ title: 'x'.repeat(400_000) });
expect(res.status).toBe(413);
});
});