Skip to content

Commit 0a749e6

Browse files
committed
test(rest): the by-id route answers the empty projection at its existing projection-refusal status
Claude-Session: https://claude.ai/code/session_01FEkQ5kRR5RttkLiWWAkDA5 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0d5e75c commit 0a749e6

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎packages/rest/src/data-empty-projection-count-door.test.ts‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* | `GET ?$count=maybe`, `?$count=1`, `?count=` (with `$top`) | 200, `total` reported | 400 naming the spelling |
1616
* | `POST {"select":""}`, `{"fields":[]}` | 200, every column | 400 naming the key |
1717
* | `POST {"count":"maybe"}` | 400 `VALIDATION_FAILED` (the body schema) | unchanged |
18-
* | `GET /:id?select=`, `?select=,` | 200, every column | 400 naming `select` |
18+
* | `GET /:id?select=`, `?select=,` | 200, every column | `VALIDATION_ERROR` naming `select`, at this route's 404 (it rewrites every 400, as for `?select=nope`) |
1919
* | `GET ?$select=label`, `?$count=true` / `false`, absent; `GET /:id?select=label` | 200 | unchanged |
2020
*
2121
* The per-spelling pin with a recording engine is `metadata-protocol`'s
@@ -167,11 +167,17 @@ describe('[#26644] an empty projection and an unrecognised count flag on the Dat
167167
expect(res.body.code).toBe('VALIDATION_FAILED');
168168
});
169169

170-
it('GET by id: 400 VALIDATION_ERROR naming `select` — no read', async () => {
170+
it("GET by id: VALIDATION_ERROR naming `select`, at the status this route gives every projection refusal — no read", async () => {
171+
// This route's catch rewrites every 400 into a 404 (`crud-routes.ts`: "a
172+
// bad id is a miss"), so its projection refusals already answer 404 — an
173+
// unknown `select` field included. The empty projection joins that answer
174+
// rather than inventing a second one here; the code is what differs.
175+
const unknownField = await byId({ select: 'nope' });
176+
expect(unknownField.body.code, JSON.stringify(unknownField.body)).toBe('INVALID_FIELD');
171177
const before = reads.n;
172178
for (const select of ['', ',']) {
173179
const res = await byId({ select });
174-
expect(res.status, `select=${JSON.stringify(select)}: ${JSON.stringify(res.body)}`).toBe(400);
180+
expect(res.status, `select=${JSON.stringify(select)}: ${JSON.stringify(res.body)}`).toBe(unknownField.status);
175181
expect(res.body.code).toBe('VALIDATION_ERROR');
176182
expect(res.body.error).toContain("Query parameter 'select' names no field");
177183
}

0 commit comments

Comments
 (0)