@ontrails/testing 1.0.0-beta.13 → 1.0.0-beta.15
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.
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +28 -0
- package/README.md +11 -11
- package/dist/all.d.ts +10 -5
- package/dist/all.d.ts.map +1 -1
- package/dist/all.js +78 -26
- package/dist/all.js.map +1 -1
- package/dist/assertions.d.ts +23 -0
- package/dist/assertions.d.ts.map +1 -1
- package/dist/assertions.js +154 -0
- package/dist/assertions.js.map +1 -1
- package/dist/context.d.ts +17 -16
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +31 -20
- package/dist/context.js.map +1 -1
- package/dist/contracts.d.ts.map +1 -1
- package/dist/contracts.js +9 -5
- package/dist/contracts.js.map +1 -1
- package/dist/crosses.d.ts +4 -4
- package/dist/crosses.d.ts.map +1 -1
- package/dist/crosses.js +49 -39
- package/dist/crosses.js.map +1 -1
- package/dist/detours.d.ts +5 -4
- package/dist/detours.d.ts.map +1 -1
- package/dist/detours.js +93 -14
- package/dist/detours.js.map +1 -1
- package/dist/effective-examples.d.ts +30 -0
- package/dist/effective-examples.d.ts.map +1 -0
- package/dist/effective-examples.js +227 -0
- package/dist/effective-examples.js.map +1 -0
- package/dist/examples.d.ts +1 -1
- package/dist/examples.d.ts.map +1 -1
- package/dist/examples.js +79 -41
- package/dist/examples.js.map +1 -1
- package/dist/harness-cli.d.ts +3 -3
- package/dist/harness-cli.d.ts.map +1 -1
- package/dist/harness-cli.js +25 -33
- package/dist/harness-cli.js.map +1 -1
- package/dist/harness-mcp.d.ts +3 -3
- package/dist/harness-mcp.d.ts.map +1 -1
- package/dist/harness-mcp.js +9 -8
- package/dist/harness-mcp.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/scenario.d.ts +37 -0
- package/dist/scenario.d.ts.map +1 -0
- package/dist/scenario.js +235 -0
- package/dist/scenario.js.map +1 -0
- package/dist/types.d.ts +38 -5
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -5
- package/src/__tests__/all.test.ts +217 -29
- package/src/__tests__/context.test.ts +32 -12
- package/src/__tests__/contracts.test.ts +72 -18
- package/src/__tests__/crosses.test.ts +78 -78
- package/src/__tests__/detours.test.ts +176 -19
- package/src/__tests__/effective-examples.test.ts +203 -0
- package/src/__tests__/examples.test.ts +152 -50
- package/src/__tests__/harness-cli.test.ts +90 -0
- package/src/__tests__/harness-mcp.test.ts +37 -0
- package/src/__tests__/partial-match.test.ts +126 -0
- package/src/__tests__/scenario.test.ts +381 -0
- package/src/all.ts +149 -12
- package/src/assertions.ts +253 -0
- package/src/context.ts +64 -38
- package/src/contracts.ts +14 -8
- package/src/crosses.ts +93 -51
- package/src/detours.ts +155 -18
- package/src/effective-examples.ts +350 -0
- package/src/examples.ts +127 -59
- package/src/harness-cli.ts +33 -49
- package/src/harness-mcp.ts +9 -8
- package/src/index.ts +13 -3
- package/src/scenario.ts +370 -0
- package/src/types.ts +63 -5
- package/tsconfig.tests.json +10 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/dist/follows.d.ts +0 -38
- package/dist/follows.d.ts.map +0 -1
- package/dist/follows.js +0 -212
- package/dist/follows.js.map +0 -1
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Trail, TrailExample } from '@ontrails/core';
|
|
2
|
+
/**
|
|
3
|
+
* Returns `true` if the given example was synthesized from contour fixtures
|
|
4
|
+
* by `deriveTrailExamples`, `false` if it was authored on the trail.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isDerivedExample: (example: TrailExample<unknown, unknown>) => boolean;
|
|
7
|
+
/**
|
|
8
|
+
* Prefer authored trail examples and fall back to contour-derived fixtures.
|
|
9
|
+
*
|
|
10
|
+
* Examples returned by this helper come from one of two provenances:
|
|
11
|
+
* - **Authored.** When `trail.examples` is non-empty, its entries are
|
|
12
|
+
* returned verbatim. These are the developer's stated intent and carry
|
|
13
|
+
* full invariants — including crossing-coverage assertions in
|
|
14
|
+
* `testExamples`.
|
|
15
|
+
* - **Derived.** When there are no authored examples but the trail has
|
|
16
|
+
* contours with examples, candidate inputs are synthesized from contour
|
|
17
|
+
* fixtures and validated against `trail.input`. These are opportunistic
|
|
18
|
+
* coverage that exists to let `testAll(app)` exercise contour-backed
|
|
19
|
+
* trails without per-test setup; they are not guaranteed to exercise
|
|
20
|
+
* every composition branch, so consumers should relax invariants that
|
|
21
|
+
* only make sense for authored inputs (see `isDerivedExample`).
|
|
22
|
+
*
|
|
23
|
+
* Contour examples stay as the raw input payload so Trails validation /
|
|
24
|
+
* transforms still happen exactly once inside the normal test execution
|
|
25
|
+
* path. Derived examples are additionally tagged via a module-level
|
|
26
|
+
* `WeakSet` so consumers can detect them without widening the public
|
|
27
|
+
* `TrailExample` shape.
|
|
28
|
+
*/
|
|
29
|
+
export declare const deriveTrailExamples: (trail: Trail<unknown, unknown, unknown>) => readonly TrailExample<unknown, unknown>[];
|
|
30
|
+
//# sourceMappingURL=effective-examples.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective-examples.d.ts","sourceRoot":"","sources":["../src/effective-examples.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAiBtE;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAC3B,SAAS,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,KACtC,OAAuC,CAAC;AAqQ3C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,KACtC,SAAS,YAAY,CAAC,OAAO,EAAE,OAAO,CAAC,EAyCzC,CAAC"}
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import { getContourReferences } from '@ontrails/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/**
|
|
4
|
+
* Tracks examples that `deriveTrailExamples` synthesizes from contour
|
|
5
|
+
* fixtures. Authored examples are passed through untouched and never
|
|
6
|
+
* appear here, so consumers can distinguish the two by identity.
|
|
7
|
+
*
|
|
8
|
+
* Exposed via `isDerivedExample` so downstream testing helpers (e.g.
|
|
9
|
+
* `testExamples` crossing coverage) can relax invariants that only make
|
|
10
|
+
* sense for authored inputs.
|
|
11
|
+
*/
|
|
12
|
+
const derivedExamples = new WeakSet();
|
|
13
|
+
/**
|
|
14
|
+
* Returns `true` if the given example was synthesized from contour fixtures
|
|
15
|
+
* by `deriveTrailExamples`, `false` if it was authored on the trail.
|
|
16
|
+
*/
|
|
17
|
+
export const isDerivedExample = (example) => derivedExamples.has(example);
|
|
18
|
+
const capitalize = (value) => value.length === 0 ? value : value.slice(0, 1).toUpperCase() + value.slice(1);
|
|
19
|
+
const collectReferenceMap = (contours) => {
|
|
20
|
+
const contourNames = new Set(contours.map((contour) => contour.name));
|
|
21
|
+
return new Map(contours.map((contour) => [
|
|
22
|
+
contour.name,
|
|
23
|
+
getContourReferences(contour).filter((reference) => contourNames.has(reference.contour)),
|
|
24
|
+
]));
|
|
25
|
+
};
|
|
26
|
+
const getIdentityValue = (fixture) => fixture.example[fixture.contour.identity];
|
|
27
|
+
const candidateMatchesSelectedReference = (candidate, target, reference) => Object.is(candidate.example[reference.field], getIdentityValue(target));
|
|
28
|
+
const selectedMatchesCandidateReference = (fixture, candidate, reference) => Object.is(fixture.example[reference.field], getIdentityValue(candidate));
|
|
29
|
+
const matchesCandidateReferences = (candidate, selected, referencesByContour) => {
|
|
30
|
+
const candidateReferences = referencesByContour.get(candidate.contour.name) ?? [];
|
|
31
|
+
for (const reference of candidateReferences) {
|
|
32
|
+
const target = selected.find((fixture) => fixture.contour.name === reference.contour);
|
|
33
|
+
if (target === undefined) {
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
if (!candidateMatchesSelectedReference(candidate, target, reference)) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return true;
|
|
41
|
+
};
|
|
42
|
+
const matchesSelectedReferences = (candidate, selected, referencesByContour) => {
|
|
43
|
+
for (const fixture of selected) {
|
|
44
|
+
const fixtureReferences = referencesByContour.get(fixture.contour.name) ?? [];
|
|
45
|
+
for (const reference of fixtureReferences) {
|
|
46
|
+
if (reference.contour !== candidate.contour.name) {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
if (!selectedMatchesCandidateReference(fixture, candidate, reference)) {
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return true;
|
|
55
|
+
};
|
|
56
|
+
const matchesKnownReferences = (candidate, selected, referencesByContour) => matchesCandidateReferences(candidate, selected, referencesByContour) &&
|
|
57
|
+
matchesSelectedReferences(candidate, selected, referencesByContour);
|
|
58
|
+
const selectContourFixtures = (contours, referencesByContour, index = 0, selected = []) => {
|
|
59
|
+
const contour = contours[index];
|
|
60
|
+
if (contour === undefined) {
|
|
61
|
+
return [selected];
|
|
62
|
+
}
|
|
63
|
+
const examples = contour.examples ?? [];
|
|
64
|
+
const matchingFixtures = examples.flatMap((example, exampleIndex) => {
|
|
65
|
+
const fixture = {
|
|
66
|
+
contour,
|
|
67
|
+
example: example,
|
|
68
|
+
index: exampleIndex,
|
|
69
|
+
};
|
|
70
|
+
if (!matchesKnownReferences(fixture, selected, referencesByContour)) {
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
return selectContourFixtures(contours, referencesByContour, index + 1, [
|
|
74
|
+
...selected,
|
|
75
|
+
fixture,
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
return matchingFixtures;
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Merge selected contour fixtures into a single candidate input object.
|
|
82
|
+
*
|
|
83
|
+
* The resulting record contains:
|
|
84
|
+
* - `<contour>`: the full fixture payload keyed by contour name.
|
|
85
|
+
* - `<contour><Identity>`: the fixture's identity value on a prefixed key.
|
|
86
|
+
* - `<contour><Field>`: every fixture field on a prefixed key.
|
|
87
|
+
* - Unqualified `<field>` keys: first-write-wins across contours.
|
|
88
|
+
*
|
|
89
|
+
* The first-write-wins behaviour on unqualified keys is intentional but can
|
|
90
|
+
* silently drop a later contour's value when two contours share a field name
|
|
91
|
+
* (e.g. both declare `id`). The prefixed aliases above are unambiguous and
|
|
92
|
+
* always written, so schemas that consume the prefixed form are unaffected;
|
|
93
|
+
* schemas that rely on the bare field name should disambiguate via the
|
|
94
|
+
* prefixed alias instead.
|
|
95
|
+
*/
|
|
96
|
+
const buildDerivedInput = (fixtures) => {
|
|
97
|
+
const candidate = {};
|
|
98
|
+
for (const fixture of fixtures) {
|
|
99
|
+
candidate[fixture.contour.name] = fixture.example;
|
|
100
|
+
candidate[`${fixture.contour.name}${capitalize(fixture.contour.identity)}`] = getIdentityValue(fixture);
|
|
101
|
+
for (const [field, value] of Object.entries(fixture.example)) {
|
|
102
|
+
if (!Object.hasOwn(candidate, field)) {
|
|
103
|
+
candidate[field] = value;
|
|
104
|
+
}
|
|
105
|
+
candidate[`${fixture.contour.name}${capitalize(field)}`] = value;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return candidate;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Project the merged candidate input down to keys the trail's input schema
|
|
112
|
+
* knows about.
|
|
113
|
+
*
|
|
114
|
+
* `buildDerivedInput` emits synthesized prefixed aliases (e.g. `userEmail`)
|
|
115
|
+
* alongside bare field names. Strict schemas (`z.object(...).strict()`)
|
|
116
|
+
* reject any unknown key, which means an otherwise valid derived fixture
|
|
117
|
+
* would silently fail `safeParse` just because of the synthesized aliases.
|
|
118
|
+
* When the input is a `ZodObject`, trim the candidate to its declared keys
|
|
119
|
+
* before validation. Non-object inputs pass through unchanged — they are
|
|
120
|
+
* validated as-is and can decide for themselves.
|
|
121
|
+
*/
|
|
122
|
+
const projectInputForSchema = (inputSchema, candidate) => {
|
|
123
|
+
if (!(inputSchema instanceof z.ZodObject)) {
|
|
124
|
+
return candidate;
|
|
125
|
+
}
|
|
126
|
+
const known = Object.keys(inputSchema.shape);
|
|
127
|
+
const projected = {};
|
|
128
|
+
for (const key of known) {
|
|
129
|
+
if (Object.hasOwn(candidate, key)) {
|
|
130
|
+
projected[key] = candidate[key];
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return projected;
|
|
134
|
+
};
|
|
135
|
+
/**
|
|
136
|
+
* Derive an expected output value from the selected contour fixtures when
|
|
137
|
+
* exactly one fixture's payload satisfies the trail's output schema.
|
|
138
|
+
*
|
|
139
|
+
* Returns `undefined` when the trail has no output schema, when no fixture
|
|
140
|
+
* matches, or when more than one matches — callers should then leave the
|
|
141
|
+
* derived example without an `expected` and fall back to schema-only
|
|
142
|
+
* validation. We intentionally do **not** infer `expected` from the merged
|
|
143
|
+
* candidate input: input and output schemas frequently overlap structurally
|
|
144
|
+
* but represent different semantics, so inferring from the input would
|
|
145
|
+
* produce false deep-equality failures.
|
|
146
|
+
*/
|
|
147
|
+
const deriveExpectedValue = (trail, fixtures) => {
|
|
148
|
+
if (trail.output === undefined) {
|
|
149
|
+
return undefined;
|
|
150
|
+
}
|
|
151
|
+
const outputSchema = trail.output;
|
|
152
|
+
const contourMatches = fixtures
|
|
153
|
+
.map((fixture) => outputSchema.safeParse(fixture.example))
|
|
154
|
+
.filter((candidate) => candidate.success);
|
|
155
|
+
if (contourMatches.length !== 1) {
|
|
156
|
+
return undefined;
|
|
157
|
+
}
|
|
158
|
+
const [singleMatch] = contourMatches;
|
|
159
|
+
if (singleMatch === undefined) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
return singleMatch.data;
|
|
163
|
+
};
|
|
164
|
+
const formatFixtureName = (fixtures, index) => {
|
|
165
|
+
const label = fixtures
|
|
166
|
+
.map((fixture) => {
|
|
167
|
+
const identity = getIdentityValue(fixture);
|
|
168
|
+
const fallback = fixture.index + 1;
|
|
169
|
+
return `${fixture.contour.name}:${String(identity ?? fallback)}`;
|
|
170
|
+
})
|
|
171
|
+
.join(', ');
|
|
172
|
+
return label.length > 0
|
|
173
|
+
? `Derived fixture ${index + 1} (${label})`
|
|
174
|
+
: `Derived fixture ${index + 1}`;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* Prefer authored trail examples and fall back to contour-derived fixtures.
|
|
178
|
+
*
|
|
179
|
+
* Examples returned by this helper come from one of two provenances:
|
|
180
|
+
* - **Authored.** When `trail.examples` is non-empty, its entries are
|
|
181
|
+
* returned verbatim. These are the developer's stated intent and carry
|
|
182
|
+
* full invariants — including crossing-coverage assertions in
|
|
183
|
+
* `testExamples`.
|
|
184
|
+
* - **Derived.** When there are no authored examples but the trail has
|
|
185
|
+
* contours with examples, candidate inputs are synthesized from contour
|
|
186
|
+
* fixtures and validated against `trail.input`. These are opportunistic
|
|
187
|
+
* coverage that exists to let `testAll(app)` exercise contour-backed
|
|
188
|
+
* trails without per-test setup; they are not guaranteed to exercise
|
|
189
|
+
* every composition branch, so consumers should relax invariants that
|
|
190
|
+
* only make sense for authored inputs (see `isDerivedExample`).
|
|
191
|
+
*
|
|
192
|
+
* Contour examples stay as the raw input payload so Trails validation /
|
|
193
|
+
* transforms still happen exactly once inside the normal test execution
|
|
194
|
+
* path. Derived examples are additionally tagged via a module-level
|
|
195
|
+
* `WeakSet` so consumers can detect them without widening the public
|
|
196
|
+
* `TrailExample` shape.
|
|
197
|
+
*/
|
|
198
|
+
export const deriveTrailExamples = (trail) => {
|
|
199
|
+
if (trail.examples !== undefined && trail.examples.length > 0) {
|
|
200
|
+
return trail.examples;
|
|
201
|
+
}
|
|
202
|
+
if (trail.contours.length === 0) {
|
|
203
|
+
return [];
|
|
204
|
+
}
|
|
205
|
+
if (trail.contours.some((contour) => contour.examples === undefined || contour.examples.length === 0)) {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
const referencesByContour = collectReferenceMap(trail.contours);
|
|
209
|
+
const fixtureSets = selectContourFixtures(trail.contours, referencesByContour);
|
|
210
|
+
return fixtureSets.flatMap((fixtures, index) => {
|
|
211
|
+
const merged = buildDerivedInput(fixtures);
|
|
212
|
+
const input = projectInputForSchema(trail.input, merged);
|
|
213
|
+
const validated = trail.input.safeParse(input);
|
|
214
|
+
if (!validated.success) {
|
|
215
|
+
return [];
|
|
216
|
+
}
|
|
217
|
+
const expected = deriveExpectedValue(trail, fixtures);
|
|
218
|
+
const derived = {
|
|
219
|
+
...(expected === undefined ? {} : { expected }),
|
|
220
|
+
input,
|
|
221
|
+
name: formatFixtureName(fixtures, index),
|
|
222
|
+
};
|
|
223
|
+
derivedExamples.add(derived);
|
|
224
|
+
return [derived];
|
|
225
|
+
});
|
|
226
|
+
};
|
|
227
|
+
//# sourceMappingURL=effective-examples.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effective-examples.js","sourceRoot":"","sources":["../src/effective-examples.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB;;;;;;;;GAQG;AACH,MAAM,eAAe,GAAG,IAAI,OAAO,EAAkC,CAAC;AAEtE;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,OAAuC,EAC9B,EAAE,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AAQ3C,MAAM,UAAU,GAAG,CAAC,KAAa,EAAU,EAAE,CAC3C,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAEhF,MA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;AACL,CAAC,CAAC"}
|
package/dist/examples.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ import type { TestExecutionOptions } from './context.js';
|
|
|
16
16
|
*
|
|
17
17
|
* One line in your test file:
|
|
18
18
|
* ```ts
|
|
19
|
-
* testExamples(
|
|
19
|
+
* testExamples(graph);
|
|
20
20
|
* ```
|
|
21
21
|
*/
|
|
22
22
|
export declare const testExamples: (app: Topo, ctxOrFactory?: Partial<TrailContext> | TestExecutionOptions | (() => Partial<TrailContext> | TestExecutionOptions)) => void;
|
package/dist/examples.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAGV,IAAI,EAGJ,YAAY,EACb,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"examples.d.ts","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,KAAK,EAGV,IAAI,EAGJ,YAAY,EACb,MAAM,gBAAgB,CAAC;AAuCxB,OAAO,KAAK,EAAkB,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAmPzE;;;;;;;;;;GAUG;AACH,eAAO,MAAM,YAAY,GACvB,KAAK,IAAI,EACT,eACI,OAAO,CAAC,YAAY,CAAC,GACrB,oBAAoB,GACpB,CAAC,MAAM,OAAO,CAAC,YAAY,CAAC,GAAG,oBAAoB,CAAC,KACvD,IAoGF,CAAC"}
|
package/dist/examples.js
CHANGED
|
@@ -7,9 +7,10 @@
|
|
|
7
7
|
* declarations, checks that every declared crossing was called at least once.
|
|
8
8
|
*/
|
|
9
9
|
import { describe, expect, test } from 'bun:test';
|
|
10
|
-
import { AlreadyExistsError, AmbiguousError, AssertionError, AuthError, CancelledError, ConflictError, InternalError, NetworkError, NotFoundError, PermissionError, RateLimitError, executeTrail, Result, TimeoutError, TrailsError, ValidationError, validateInput, } from '@ontrails/core';
|
|
11
|
-
import { assertErrorMatch, assertFullMatch, assertSchemaMatch, } from './assertions.js';
|
|
12
|
-
import {
|
|
10
|
+
import { AlreadyExistsError, AmbiguousError, AssertionError, AuthError, buildCrossValidationSchema, CancelledError, ConflictError, DerivationError, InternalError, NetworkError, NotFoundError, PermissionError, RateLimitError, RetryExhaustedError, executeTrail, Result, TimeoutError, TrailsError, ValidationError, validateInput, } from '@ontrails/core';
|
|
11
|
+
import { assertErrorMatch, assertFullMatch, assertPartialMatch, assertSchemaMatch, } from './assertions.js';
|
|
12
|
+
import { defaultCreatePermit, mergeResourceOverrides, mergeTestContext, normalizeTestExecutionOptions, createMockResources, } from './context.js';
|
|
13
|
+
import { isDerivedExample, deriveTrailExamples } from './effective-examples.js';
|
|
13
14
|
// ---------------------------------------------------------------------------
|
|
14
15
|
// Error class name -> constructor map
|
|
15
16
|
// ---------------------------------------------------------------------------
|
|
@@ -20,11 +21,13 @@ const ERROR_MAP = {
|
|
|
20
21
|
AuthError: AuthError,
|
|
21
22
|
CancelledError: CancelledError,
|
|
22
23
|
ConflictError: ConflictError,
|
|
24
|
+
DerivationError: DerivationError,
|
|
23
25
|
InternalError: InternalError,
|
|
24
26
|
NetworkError: NetworkError,
|
|
25
27
|
NotFoundError: NotFoundError,
|
|
26
28
|
PermissionError: PermissionError,
|
|
27
29
|
RateLimitError: RateLimitError,
|
|
30
|
+
RetryExhaustedError: RetryExhaustedError,
|
|
28
31
|
TimeoutError: TimeoutError,
|
|
29
32
|
TrailsError: TrailsError,
|
|
30
33
|
ValidationError: ValidationError,
|
|
@@ -39,13 +42,13 @@ const resolveErrorClass = (name) => ERROR_MAP[name] ?? Error;
|
|
|
39
42
|
// ---------------------------------------------------------------------------
|
|
40
43
|
const assertProgressiveMatch = (result, example, output) => {
|
|
41
44
|
if (example.expected !== undefined) {
|
|
42
|
-
assertFullMatch(result, example.expected);
|
|
43
|
-
|
|
45
|
+
return assertFullMatch(result, example.expected);
|
|
46
|
+
}
|
|
47
|
+
if (example.expectedMatch !== undefined) {
|
|
48
|
+
return assertPartialMatch(result, example.expectedMatch);
|
|
44
49
|
}
|
|
45
50
|
if (example.error !== undefined) {
|
|
46
|
-
|
|
47
|
-
assertErrorMatch(result, errorClass);
|
|
48
|
-
return;
|
|
51
|
+
return assertErrorMatch(result, resolveErrorClass(example.error));
|
|
49
52
|
}
|
|
50
53
|
assertSchemaMatch(result, output);
|
|
51
54
|
};
|
|
@@ -66,18 +69,18 @@ const handleValidationError = (validated, example) => {
|
|
|
66
69
|
throw new Error(`Example "${example.name}" has invalid input: ${validated.error.message}`);
|
|
67
70
|
};
|
|
68
71
|
/**
|
|
69
|
-
* Apply auto-
|
|
70
|
-
* doesn't already have a permit,
|
|
72
|
+
* Apply auto-permit: if the trail declares scoped permits and the context
|
|
73
|
+
* doesn't already have a permit, create one and merge it into the context.
|
|
71
74
|
*/
|
|
72
|
-
const
|
|
75
|
+
const applyAutoPermit = (ctx, trailDef, opts) => {
|
|
73
76
|
if (opts.strictPermits) {
|
|
74
77
|
return ctx;
|
|
75
78
|
}
|
|
76
79
|
if (ctx.permit !== undefined) {
|
|
77
80
|
return ctx;
|
|
78
81
|
}
|
|
79
|
-
const
|
|
80
|
-
const permit =
|
|
82
|
+
const create = opts.createPermit ?? defaultCreatePermit;
|
|
83
|
+
const permit = create(trailDef);
|
|
81
84
|
if (!permit) {
|
|
82
85
|
return ctx;
|
|
83
86
|
}
|
|
@@ -87,15 +90,15 @@ const applyAutoMint = (ctx, trailDef, opts) => {
|
|
|
87
90
|
* Run a single example against a trail.
|
|
88
91
|
* Handles validation, execution, and assertions.
|
|
89
92
|
*/
|
|
90
|
-
const runExample = async (t, example, output, testCtx,
|
|
93
|
+
const runExample = async (t, example, output, testCtx, resources, opts) => {
|
|
91
94
|
const validated = validateInput(t.input, example.input);
|
|
92
95
|
if (handleValidationError(validated, example)) {
|
|
93
96
|
return;
|
|
94
97
|
}
|
|
95
|
-
const ctx = opts ?
|
|
98
|
+
const ctx = opts ? applyAutoPermit(testCtx, t, opts) : testCtx;
|
|
96
99
|
const result = await executeTrail(t, example.input, {
|
|
97
100
|
ctx,
|
|
98
|
-
|
|
101
|
+
resources: resources ?? opts?.resources,
|
|
99
102
|
});
|
|
100
103
|
assertProgressiveMatch(result, example, output);
|
|
101
104
|
};
|
|
@@ -109,37 +112,51 @@ const runExample = async (t, example, output, testCtx, provisions, opts) => {
|
|
|
109
112
|
* in the topo and executes it with validated input. Falls back to
|
|
110
113
|
* `Result.ok()` when neither is available.
|
|
111
114
|
*/
|
|
112
|
-
const createCoverageCross = (called, baseCross, topo, ctx,
|
|
113
|
-
const
|
|
115
|
+
const createCoverageCross = (called, baseCross, topo, ctx, resources) => {
|
|
116
|
+
const invokeCross = async (idOrTrail, input, self) => {
|
|
117
|
+
const id = typeof idOrTrail === 'string' ? idOrTrail : idOrTrail.id;
|
|
114
118
|
called.add(id);
|
|
115
119
|
if (baseCross !== undefined) {
|
|
116
|
-
return baseCross(id, input);
|
|
120
|
+
return await baseCross(id, input);
|
|
117
121
|
}
|
|
118
122
|
const trailDef = topo.get(id);
|
|
119
123
|
if (trailDef !== undefined) {
|
|
120
|
-
return executeTrail(trailDef, input, {
|
|
121
|
-
ctx: { ...ctx, cross },
|
|
122
|
-
|
|
124
|
+
return await executeTrail(trailDef, input, {
|
|
125
|
+
ctx: { ...ctx, cross: self },
|
|
126
|
+
resources,
|
|
127
|
+
validationSchema: buildCrossValidationSchema(trailDef),
|
|
123
128
|
});
|
|
124
129
|
}
|
|
125
|
-
return
|
|
130
|
+
return Result.ok();
|
|
131
|
+
};
|
|
132
|
+
// Accepts either a trail object (typed cross), a string id (untyped),
|
|
133
|
+
// or a batch of `[target, input]` tuples.
|
|
134
|
+
const cross = async function cross(idOrTrail, input) {
|
|
135
|
+
if (Array.isArray(idOrTrail)) {
|
|
136
|
+
return await Promise.all(idOrTrail.map(([target, batchInput]) => invokeCross(target, batchInput, cross)));
|
|
137
|
+
}
|
|
138
|
+
return await invokeCross(idOrTrail, input, cross);
|
|
126
139
|
};
|
|
127
140
|
return cross;
|
|
128
141
|
};
|
|
129
142
|
/**
|
|
130
143
|
* Run a single example against a trail with crossings, recording cross calls.
|
|
131
144
|
*/
|
|
132
|
-
const runCompositionExample = async (trailDef, example, output, baseCtx, called, topo,
|
|
145
|
+
const runCompositionExample = async (trailDef, example, output, baseCtx, called, topo, resources, opts) => {
|
|
133
146
|
const validated = validateInput(trailDef.input, example.input);
|
|
134
147
|
if (handleValidationError(validated, example)) {
|
|
135
148
|
return;
|
|
136
149
|
}
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
150
|
+
const permittedCtx = opts
|
|
151
|
+
? applyAutoPermit(baseCtx, trailDef, opts)
|
|
152
|
+
: baseCtx;
|
|
153
|
+
const cross = createCoverageCross(called, permittedCtx.cross, topo, permittedCtx, resources);
|
|
154
|
+
const testCtx = { ...permittedCtx, cross };
|
|
155
|
+
// Top-level trail validates against trail.input (not merged crossInput).
|
|
156
|
+
// Merged validation only applies to cross targets in executeFromMap/createCoverageCross.
|
|
140
157
|
const result = await executeTrail(trailDef, example.input, {
|
|
141
158
|
ctx: testCtx,
|
|
142
|
-
|
|
159
|
+
resources: resources ?? opts?.resources,
|
|
143
160
|
});
|
|
144
161
|
assertProgressiveMatch(result, example, output);
|
|
145
162
|
};
|
|
@@ -154,13 +171,17 @@ const runCompositionExample = async (trailDef, example, output, baseCtx, called,
|
|
|
154
171
|
*
|
|
155
172
|
* One line in your test file:
|
|
156
173
|
* ```ts
|
|
157
|
-
* testExamples(
|
|
174
|
+
* testExamples(graph);
|
|
158
175
|
* ```
|
|
159
176
|
*/
|
|
160
177
|
export const testExamples = (app, ctxOrFactory) => {
|
|
161
178
|
const resolveInput = typeof ctxOrFactory === 'function' ? ctxOrFactory : () => ctxOrFactory;
|
|
162
|
-
const
|
|
163
|
-
|
|
179
|
+
const withExamples = app.list()
|
|
180
|
+
.map((trailDef) => ({
|
|
181
|
+
...trailDef,
|
|
182
|
+
examples: deriveTrailExamples(trailDef),
|
|
183
|
+
}))
|
|
184
|
+
.filter((trailDef) => trailDef.examples.length > 0);
|
|
164
185
|
const simpleTrails = withExamples.filter((t) => t.crosses.length === 0);
|
|
165
186
|
const compositionTrails = withExamples.filter((t) => t.crosses.length > 0);
|
|
166
187
|
// Simple trails: run examples directly
|
|
@@ -172,30 +193,47 @@ export const testExamples = (app, ctxOrFactory) => {
|
|
|
172
193
|
}
|
|
173
194
|
test.each([...examples])('example: $name', async (example) => {
|
|
174
195
|
const resolved = normalizeTestExecutionOptions(resolveInput());
|
|
175
|
-
const
|
|
196
|
+
const resources = mergeResourceOverrides(await createMockResources(app), resolved.ctx, resolved.resources);
|
|
176
197
|
const testCtx = mergeTestContext(resolved.ctx);
|
|
177
|
-
await runExample(t, example, output, testCtx,
|
|
198
|
+
await runExample(t, example, output, testCtx, resources, resolved);
|
|
178
199
|
});
|
|
179
200
|
});
|
|
180
201
|
}
|
|
181
|
-
// Composition trails: use recording cross and check coverage
|
|
202
|
+
// Composition trails: use recording cross and check coverage.
|
|
203
|
+
//
|
|
204
|
+
// Crossing coverage only runs against AUTHORED examples. Contour-derived
|
|
205
|
+
// fixtures are opportunistic coverage that may not exercise every
|
|
206
|
+
// `ctx.cross()` branch in the trail, so asserting coverage against them
|
|
207
|
+
// would produce false failures for trails whose authored intent was a
|
|
208
|
+
// single path. When a trail has zero authored examples the coverage
|
|
209
|
+
// assertion is skipped entirely — the derived-example runs still
|
|
210
|
+
// execute, but they are not required to cover declared crossings.
|
|
182
211
|
if (compositionTrails.length > 0) {
|
|
183
212
|
describe.each(compositionTrails)('$id', (t) => {
|
|
184
213
|
const { examples, output } = t;
|
|
185
214
|
if (!examples) {
|
|
186
215
|
return;
|
|
187
216
|
}
|
|
188
|
-
const
|
|
217
|
+
const calledFromAuthored = new Set();
|
|
218
|
+
const hasAuthoredExamples = examples.some((example) => !isDerivedExample(example));
|
|
219
|
+
// Only record cross calls from authored examples. Derived fixtures
|
|
220
|
+
// execute normally but do not contribute to coverage — the sink map
|
|
221
|
+
// routes each example to the right bucket without an inline
|
|
222
|
+
// conditional inside the test body.
|
|
223
|
+
const discardSink = new Set();
|
|
224
|
+
const pickCoverageSink = (example) => isDerivedExample(example) ? discardSink : calledFromAuthored;
|
|
189
225
|
test.each([...examples])('example: $name', async (example) => {
|
|
190
226
|
const resolved = normalizeTestExecutionOptions(resolveInput());
|
|
191
|
-
const
|
|
227
|
+
const resources = mergeResourceOverrides(await createMockResources(app), resolved.ctx, resolved.resources);
|
|
192
228
|
const baseCtx = mergeTestContext(resolved.ctx);
|
|
193
|
-
await runCompositionExample(t, example, output, baseCtx,
|
|
194
|
-
});
|
|
195
|
-
test('crossing coverage', () => {
|
|
196
|
-
const uncovered = t.crosses.filter((id) => !called.has(id));
|
|
197
|
-
expect(uncovered).toEqual([]);
|
|
229
|
+
await runCompositionExample(t, example, output, baseCtx, pickCoverageSink(example), app, resources, resolved);
|
|
198
230
|
});
|
|
231
|
+
if (hasAuthoredExamples) {
|
|
232
|
+
test('crossing coverage', () => {
|
|
233
|
+
const uncovered = t.crosses.filter((id) => !calledFromAuthored.has(id));
|
|
234
|
+
expect(uncovered).toEqual([]);
|
|
235
|
+
});
|
|
236
|
+
}
|
|
199
237
|
});
|
|
200
238
|
}
|
|
201
239
|
};
|
package/dist/examples.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"examples.js","sourceRoot":"","sources":["../src/examples.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAWlD,OAAO,EACL,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,SAAS,EACT,cAAc,EACd,aAAa,EACb,aAAa,EACb,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,YAAY,EACZ,MAAM,EACN,YAAY,EACZ,WAAW,EACX,eAAe,EAC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,CAAC,CAAC,CACtB,gBAAgB,EAChB,KAAK,EAAE,OAAuC,EAAE,EAAE;gBAChD,MAAM,QAAQ,GAAG,6BAA6B,CAAC,YAAY,EAAE,CAAC,CAAC;gBAC/D,MAAM,SAAS,GAAG,sBAAsB,CACtC,MAAM,mBAAmB,CAAC,GAAG,CAAC,EAC9B,QAAQ,CAAC,GAAG,EACZ,QAAQ,CAAC,SAAS,CACnB,CAAC;gBACF,MAAM,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;gBAC/C,MAAM,qBAAqB,CACzB,CAAC,EACD,OAAO,EACP,MAAM,EACN,OAAO,EACP,gBAAgB,CAAC,OAAO,CAAC,EACzB,GAAG,EACH,SAAS,EACT,QAAQ,CACT,CAAC;YACJ,CAAC,CACF,CAAC;YAEF,IAAI,mBAAmB,EAAE,CAAC;gBACxB,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE;oBAC7B,MAAM,SAAS,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,CAChC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG,CAAC,EAAE,CAAC,CACpC,CAAC;oBACF,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC,CAAC"}
|
package/dist/harness-cli.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* CLI integration test harness.
|
|
3
3
|
*
|
|
4
|
-
* Builds CLI commands from
|
|
4
|
+
* Builds CLI commands from a graph, executes them in-process,
|
|
5
5
|
* and captures stdout/stderr.
|
|
6
6
|
*/
|
|
7
7
|
import type { CliHarness, CliHarnessOptions } from './types.js';
|
|
8
8
|
/**
|
|
9
9
|
* Create a CLI harness for integration testing.
|
|
10
10
|
*
|
|
11
|
-
* Builds commands from the
|
|
11
|
+
* Builds commands from the graph's topo and provides a `run()` method
|
|
12
12
|
* that parses command strings and executes them in-process.
|
|
13
13
|
*
|
|
14
14
|
* ```ts
|
|
15
|
-
* const harness = createCliHarness({
|
|
15
|
+
* const harness = createCliHarness({ graph });
|
|
16
16
|
* const result = await harness.run("entity show --name Alpha --output json");
|
|
17
17
|
* expect(result.exitCode).toBe(0);
|
|
18
18
|
* ```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"harness-cli.d.ts","sourceRoot":"","sources":["../src/harness-cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"harness-cli.d.ts","sourceRoot":"","sources":["../src/harness-cli.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,OAAO,KAAK,EACV,UAAU,EACV,iBAAiB,EAElB,MAAM,YAAY,CAAC;AA8PpB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,gBAAgB,GAAI,SAAS,iBAAiB,KAAG,UAW7D,CAAC"}
|