@substrat-run/contract-tests 0.124.0 → 0.125.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,4 @@
1
+ import { type ErrorCode } from '@substrat-run/contracts';
1
2
  import { type ScopeHost } from '@substrat-run/kernel';
2
3
  export interface ScopeHostFixture {
3
4
  host: ScopeHost;
@@ -10,6 +11,28 @@ export interface ScopeHostFixture {
10
11
  versionId?: string;
11
12
  cleanup(): Promise<void>;
12
13
  }
14
+ /**
15
+ * Assert a refusal by the CODE it declared, not by the sentence it happens to carry
16
+ * (#113 phase 5).
17
+ *
18
+ * `errorCodeOf` is the same reading the control plane's `mapError` does, so what this
19
+ * pins and the problem document a transport renders agree by construction. A `/message/`
20
+ * match agreed with it only by coincidence — and that coincidence was load-bearing:
21
+ * `CODE_PATTERNS` in `packages/control-plane-api/src/errors.ts` guessed the code by
22
+ * regex, so rewording a throw silently changed a 404 into a 500, and the suite's own
23
+ * message assertion was the only thing standing in the way. Moving the assertion here
24
+ * makes the message free to change and the TYPE the thing that cannot.
25
+ *
26
+ * A promise that RESOLVES fails this too: `errorCodeOf(undefined)` is `undefined`, which
27
+ * is never a code — so it cannot pass by not throwing at all.
28
+ *
29
+ * `message` is for the minority of refusals where the sentence carries something the code
30
+ * cannot: WHICH branch fired, when two branches share one code. `deleteVertical` refuses a
31
+ * live scope with "delete or rebind" and an archived one with "reap or restore" — both
32
+ * `conflict`, and an adapter that answered the wrong one would send an operator to a button
33
+ * that is not there. Pass it only for that; a code is the contract everywhere else.
34
+ */
35
+ export declare const expectRefusal: (p: Promise<unknown>, code: ErrorCode, message?: RegExp) => Promise<void>;
13
36
  /** Adapter capability flags — everything an adapter cannot honor identically. */
14
37
  export interface ScopeHostSuiteOptions {
15
38
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"scope-host-suite.d.ts","sourceRoot":"","sources":["../src/scope-host-suite.ts"],"names":[],"mappings":"AA4BA,OAAO,EAO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CAuoON"}
@@ -24,7 +24,7 @@ import { billedMod, contractTestBareOps, contractTestInitialModules, gateModMani
24
24
  * `conflict`, and an adapter that answered the wrong one would send an operator to a button
25
25
  * that is not there. Pass it only for that; a code is the contract everywhere else.
26
26
  */
27
- const expectRefusal = async (p, code, message) => {
27
+ export const expectRefusal = async (p, code, message) => {
28
28
  const err = await p.then(() => undefined, (e) => e);
29
29
  expect(errorCodeOf(err)).toBe(code);
30
30
  if (message !== undefined)