Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions packages/qa/dogfood/test/error-sentences-live.dogfood.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
//
// - acceptance[1]: a sandboxed `beforeInsert` hook that throws a business
// sentence and declares no code. `POST /data/OBJECT` and its `/createMany`
// door answer 400 carrying the sentence verbatim and NO `code` (by pinned
// design on the /data door), and no row is written.
// door answer 400 carrying the sentence verbatim and the ruled
// `code: 'HOOK_ABORTED'` (#27597: an undeclared hook abort answers the
// ledgered code, a declared one is kept), and no row is written.
// - acceptance[2]: a declarative `operation: 'update'` action whose patch
// repeats a `unique: true` email: `POST /actions/OBJECT/ACTION` answers
// 409 UNIQUE_VIOLATION, `error.details` carries exactly `developerMessage`
Expand Down Expand Up @@ -71,12 +72,12 @@ describe('[#26572] error answers made honest, over HTTP on a booted scratch app'
];

for (const [door, send] of doors) {
it(`${door}: 400 with the hook's own sentence, no code, nothing written`, async () => {
it(`${door}: 400 with the hook's own sentence, HOOK_ABORTED, nothing written`, async () => {
const res = await send();
const body: any = await res.json();
expect(res.status, JSON.stringify(body)).toBe(400);
expect(body.error).toBe(HOOK_SENTENCE);
expect('code' in body, `the hook declared no code, so the /data door carries none: ${JSON.stringify(body)}`).toBe(false);
expect(body.code, `the hook declared no code, so the /data door answers the ruled HOOK_ABORTED: ${JSON.stringify(body)}`).toBe('HOOK_ABORTED');
expect(await ql.find('errsent_budget', { where: {}, ...SYS })).toHaveLength(0);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,11 @@ describe('records-forms.object-hook-lifecycle — the scratch hook variants over
}
expect(res.status, res.text).toBe(400);
expect(res.text).toContain(ABORT_MSG);
// [#27508] The abort is a refusal the route answered: the wire answer is
// the hook's own sentence, code-less, exactly as before, and the server
// does not log it as an unhandled error.
expect(res.json).toEqual({ error: ABORT_MSG, object: ABORT });
// [#27508] The abort is a refusal the route answered, and the server does
// not log it as an unhandled error. [#27597] The wire answer is the hook's
// own sentence plus the ruled `HOOK_ABORTED`, since the hook declared no
// code (a declared code is kept).
expect(res.json).toEqual({ error: ABORT_MSG, code: 'HOOK_ABORTED', object: ABORT });
expect(log.matching('[REST] Unhandled error')).toHaveLength(0);
expect(await stack.rows(ABORT, { name: 'ohl-abort' })).toHaveLength(0);
});
Expand Down
Loading