From 7f26b4ba467e1fc4a8ff065d9e446cb9c393847c Mon Sep 17 00:00:00 2001 From: Codeman maintainer Date: Fri, 9 Oct 2026 04:52:24 +0200 Subject: [PATCH] fix(screenshots): #551 landing fixes Pin the deprecation warning on every /api/screenshots route. The PR's test sends two GET /api/screenshots requests and checks that exactly one warning comes out, which proves the once-flag but not the individual calls: the POST and GET /:name warn calls could be deleted and it would stay green. A new it.each sends one request per route (GET list, a non-multipart POST that reaches the handler before the content-type check, and GET /:name for a missing file) on the fresh per-test harness, and each case asserts exactly one warning naming POST /api/sessions/:id/paste-image. Removing any single warn call now fails its own case (checked by deleting each call in turn). The deprecation's CHANGELOG note, required by docs/versioning-policy.md for a deprecated covered surface, rides the consolidated release changeset rather than a file here, since the PR added none. Co-Authored-By: Claude Opus 5.5 (1M context) --- test/routes/system-routes.test.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/test/routes/system-routes.test.ts b/test/routes/system-routes.test.ts index 6087e7c4..0cd44d47 100644 --- a/test/routes/system-routes.test.ts +++ b/test/routes/system-routes.test.ts @@ -696,6 +696,31 @@ describe('system-routes', () => { warn.mockRestore(); } }); + + // One request per route on the fresh per-test harness, so each warn call is pinned on its own + // (the once-flag would let the first route's warning mask a missing call on the others). + it.each([ + { label: 'GET /api/screenshots', method: 'GET' as const, url: '/api/screenshots' }, + { + label: 'POST /api/screenshots', + method: 'POST' as const, + url: '/api/screenshots', + payload: { file: 'data' }, + headers: { 'content-type': 'application/json' }, + }, + { label: 'GET /api/screenshots/:name', method: 'GET' as const, url: '/api/screenshots/nonexistent.png' }, + ])('$label warns that it is deprecated', async ({ method, url, payload, headers }) => { + const warn = vi.spyOn(console, 'warn').mockImplementation(() => {}); + try { + mockedExistsSync.mockReturnValue(false); + await harness.app.inject({ method, url, payload, headers }); + const deprecations = warn.mock.calls.filter((c) => String(c[0]).includes('/api/screenshots')); + expect(deprecations).toHaveLength(1); + expect(String(deprecations[0][0])).toContain('POST /api/sessions/:id/paste-image'); + } finally { + warn.mockRestore(); + } + }); }); // ========== GET /api/screenshots/:name ==========