mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-10-10 01:09:43 +02:00
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) <noreply@anthropic.com>
This commit is contained in:
@@ -696,6 +696,31 @@ describe('system-routes', () => {
|
|||||||
warn.mockRestore();
|
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 ==========
|
// ========== GET /api/screenshots/:name ==========
|
||||||
|
|||||||
Reference in New Issue
Block a user