mirror of
https://github.com/nexu-io/open-design.git
synced 2026-05-31 19:04:39 +07:00
test(contracts): cover runtime def error code in contracts lane
This commit is contained in:
parent
59246ca5ac
commit
5346fd7484
2 changed files with 18 additions and 23 deletions
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
import { afterEach, describe, expect, it } from 'vitest';
|
||||
import { API_ERROR_CODES, type ApiErrorCode } from '@open-design/contracts';
|
||||
import {
|
||||
assertValidRuntimeDefInactivityTimeoutMs,
|
||||
resolveChatRunInactivityTimeoutMs,
|
||||
|
|
@ -217,25 +216,3 @@ describe('assertValidRuntimeDefInactivityTimeoutMs (#2579 fast-fail at def-selec
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
describe('AGENT_RUNTIME_DEF_INVALID contract surface (#2579 review follow-up)', () => {
|
||||
// The chat-run startup path emits this code through `design.runs.fail`,
|
||||
// which feeds the shared SSE/status error envelopes — i.e. the
|
||||
// daemon/web/CLI wire contract. The previous follow-up introduced the
|
||||
// string at the daemon emit site only, so downstream consumers reading
|
||||
// `ApiErrorCode` saw a value not in the union. Land it in
|
||||
// `packages/contracts/src/errors.ts#API_ERROR_CODES` so the contract
|
||||
// catches up and any future web/CLI consumer can switch on it.
|
||||
|
||||
it('AGENT_RUNTIME_DEF_INVALID is exposed by the shared contracts package so daemon/web/CLI agree on the union', () => {
|
||||
expect((API_ERROR_CODES as readonly string[])).toContain('AGENT_RUNTIME_DEF_INVALID');
|
||||
});
|
||||
|
||||
it('the literal is assignable to ApiErrorCode (compile-time wire-contract check)', () => {
|
||||
// If the union ever loses this member again, the assignment below
|
||||
// becomes a type error; the runtime expect just keeps the spec
|
||||
// executable so the regression surfaces in CI.
|
||||
const code: ApiErrorCode = 'AGENT_RUNTIME_DEF_INVALID';
|
||||
expect(code).toBe('AGENT_RUNTIME_DEF_INVALID');
|
||||
});
|
||||
});
|
||||
|
|
|
|||
18
packages/contracts/tests/error-codes.test.ts
Normal file
18
packages/contracts/tests/error-codes.test.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { API_ERROR_CODES, type ApiErrorCode } from '../src/errors';
|
||||
|
||||
describe('shared API error codes', () => {
|
||||
it('exposes AGENT_RUNTIME_DEF_INVALID for runtime-def validation failures', () => {
|
||||
// Chat-run startup emits this code through the shared SSE/status error
|
||||
// envelopes when a checked-in runtime def is invalid. Keeping the
|
||||
// assertion in the contracts package ensures contract-only refactors
|
||||
// cannot drop the literal without this package's own test lane failing.
|
||||
expect(API_ERROR_CODES).toContain('AGENT_RUNTIME_DEF_INVALID');
|
||||
});
|
||||
|
||||
it('keeps AGENT_RUNTIME_DEF_INVALID assignable to ApiErrorCode', () => {
|
||||
const code: ApiErrorCode = 'AGENT_RUNTIME_DEF_INVALID';
|
||||
expect(code).toBe('AGENT_RUNTIME_DEF_INVALID');
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue