@enspirit/opspicy 0.4.0 → 0.6.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.
- package/README.md +33 -14
- package/bin/help.js +2 -1
- package/dist/explorer/api.js +158 -9
- package/dist/explorer/asking.js +51 -0
- package/dist/explorer/dependencies.js +117 -0
- package/dist/explorer/depending.js +139 -0
- package/dist/explorer/diagrams.js +176 -0
- package/dist/explorer/document.js +1 -0
- package/dist/explorer/elo.js +18 -0
- package/dist/explorer/pages.js +5 -2
- package/dist/explorer/script/depending.js +41 -0
- package/dist/explorer/script/main.js +1 -0
- package/dist/explorer/script/review.js +1 -1
- package/dist/explorer/script/run.js +4 -1
- package/dist/explorer/script/runner.js +420 -0
- package/dist/explorer/script/running.js +111 -0
- package/dist/explorer/script/sending.js +1 -1
- package/dist/explorer/script/served.js +4 -2
- package/dist/explorer/serve.js +1 -1
- package/dist/explorer/server.js +28 -6
- package/dist/explorer/site.js +1 -1
- package/dist/explorer/style.css +91 -1
- package/dist/explorer/telling.js +2 -0
- package/dist/explorer/tests.js +51 -18
- package/dist/explorer/wiki.js +4 -1
- package/package.json +3 -2
package/dist/explorer/site.js
CHANGED
|
@@ -11,7 +11,7 @@ import { documentOf } from './document.js';
|
|
|
11
11
|
import { wikiOf } from './wiki.js';
|
|
12
12
|
const here = (path) => new URL(path, import.meta.url);
|
|
13
13
|
/** The parts of the page's script, in the order they are read: a part names what those before it declare. The buttons of a row are in the order of the parts that add them: ƒ (rows), ▶ (run), ✎ (notes). */
|
|
14
|
-
const PARTS = ['base', 'formaldef', 'ranking', 'search', 'rows', 'filter', 'peeking', 'peek', 'markdown', 'noting', 'calling', 'copying', 'served', 'running', 'run', 'notes', 'review', 'connection', 'sending', 'call', 'main'];
|
|
14
|
+
const PARTS = ['base', 'formaldef', 'ranking', 'search', 'rows', 'filter', 'peeking', 'peek', 'markdown', 'noting', 'calling', 'copying', 'served', 'running', 'run', 'runner', 'notes', 'review', 'connection', 'sending', 'call', 'depending', 'main'];
|
|
15
15
|
/** The style, with its one font inside it: the page fetches nothing. */
|
|
16
16
|
const styleHere = () => {
|
|
17
17
|
const font = readFileSync(here('./fonts/dm-sans-latin.woff2')).toString('base64');
|
package/dist/explorer/style.css
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
--ok:light-dark(#0b7a62,#18bf97);--ko:light-dark(#c2391e,#ff9b85);
|
|
13
13
|
--yellow:#ffee7f;--green:#18bf97;--orange:#f7a336;--blue:#728dee;--light-blue:#b4c7fd;--melon:#f5cab2;--on-accent:#110e25;
|
|
14
14
|
--shade:rgba(17,14,37,.26);--veil:rgba(17,14,37,.45);
|
|
15
|
-
--note:light-dark(#fff3a8,#3a3413);--run:light-dark(#e6ecff,#1d2347);--bad:light-dark(#fbe3d6,#3b1f1a);
|
|
15
|
+
--note:light-dark(#fff3a8,#3a3413);--run:light-dark(#e6ecff,#1d2347);--bad:light-dark(#fbe3d6,#3b1f1a);--log:light-dark(#110e25,#0b091b);--on-log:#fff6e5;
|
|
16
16
|
--t-key:light-dark(#6a45c9,#c9b6ff);--t-type:light-dark(#0b7a62,#5fd9bb);--t-str:light-dark(#9a5200,#f7c27a);--t-num:light-dark(#9a5200,#f7c27a);
|
|
17
17
|
--sans:"DM Sans",system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;--opsz:"opsz" 14;--mono:ui-monospace,"SF Mono",Menlo,Consolas,monospace;--sign:Georgia,"Times New Roman",serif}
|
|
18
18
|
:root[data-theme=light]{color-scheme:light}:root[data-theme=dark]{color-scheme:dark}
|
|
@@ -224,6 +224,44 @@ dialog .bar{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
|
|
|
224
224
|
#peek .k{font-size:11.5px;color:var(--muted);letter-spacing:.08em;text-transform:uppercase}
|
|
225
225
|
#peek p{margin:4px 0 0}
|
|
226
226
|
#peek pre.elo{margin-top:8px;font-size:12.5px;max-height:220px;overflow:hidden}
|
|
227
|
+
/* The runner: every case under its operation, every operation under its area, in one table that folds, says how a run goes on its own rows, and opens a case on what its run told. */
|
|
228
|
+
.runner{margin:26px 0 0}
|
|
229
|
+
.rn-bar{background:var(--run);border-radius:10px;padding:12px 14px;font-size:14px;display:grid;gap:8px;margin:0 0 16px}
|
|
230
|
+
.rn-bar .line{display:flex;flex-wrap:wrap;gap:8px 12px;align-items:center}.rn-bar .sp{flex:1}
|
|
231
|
+
.rn-bar p{margin:0}.rn-bar :is(p,.outcome):empty{display:none}
|
|
232
|
+
.rn-bar pre{flex:1 1 20ch;margin:0;padding:8px 12px;border-radius:8px;background:var(--panel);white-space:pre-wrap;overflow-wrap:anywhere;font-size:13px}
|
|
233
|
+
.rn-bar .prog{font-variant-numeric:tabular-nums;font-weight:600}
|
|
234
|
+
.rn-bar select{height:32px;border:1px solid var(--rule);border-radius:8px;background:var(--panel);padding:0 6px;font-size:14px}
|
|
235
|
+
.rn-only{display:inline-flex;align-items:center;gap:6px;min-height:32px;cursor:pointer}.rn-only input{width:16px;height:16px;margin:0;accent-color:var(--ink)}
|
|
236
|
+
.rn-whole{flex:0 1 200px}.rn-whole .rn-meter{height:8px}
|
|
237
|
+
.rn-meter{display:flex;height:6px;border-radius:999px;overflow:hidden;background:color-mix(in srgb,var(--ink) 14%,transparent)}
|
|
238
|
+
.rn-meter .ok{background:var(--ok)}.rn-meter .ko{background:var(--ko)}
|
|
239
|
+
table.rn{width:100%;min-width:640px;font-size:14.5px;line-height:1.45;border-collapse:collapse}
|
|
240
|
+
table.rn thead th{font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted);padding:0 12px 8px 0;border-bottom:2px solid var(--ink);text-align:left;white-space:nowrap}
|
|
241
|
+
table.rn tbody :is(th,td){padding:7px 12px 7px 0;border-bottom:1px solid var(--rule);vertical-align:middle;text-align:left;font-weight:400}
|
|
242
|
+
table.rn tr>:first-child{padding-left:var(--bleed)}table.rn tr>:last-child{padding-right:var(--bleed)}
|
|
243
|
+
table.rn .rn-time{width:1%;text-align:right;white-space:nowrap;color:var(--muted);font-size:13px;font-variant-numeric:tabular-nums}
|
|
244
|
+
table.rn .rn-res{width:1%;white-space:nowrap}
|
|
245
|
+
table.rn .rn-run{width:1%;text-align:right}.runner:not(.runs) .rn-run{display:none}
|
|
246
|
+
table.rn tr.rn-op>.rn-name{padding-left:calc(var(--bleed) + 24px)}table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 48px)}
|
|
247
|
+
.runner[data-scope] table.rn tr.rn-op>.rn-name{padding-left:var(--bleed)}.runner[data-scope] table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 24px)}
|
|
248
|
+
tr.rn-area>*{background:var(--code)}tr.rn-area .rn-what{font-weight:700;font-size:16px}tr.rn-op .rn-what{font-weight:700}
|
|
249
|
+
tr:is(.rn-area,.rn-op) .rn-what{margin-right:8px}
|
|
250
|
+
.runner[data-filled] tr:is(.rn-area,.rn-op,.rn-case){cursor:pointer}.runner[data-filled] tr:is(.rn-op,.rn-case):hover>*{background:var(--hover)}
|
|
251
|
+
.rn-tw{display:inline-grid;place-items:center;width:24px;height:24px;margin:0 6px 0 -4px;padding:0;border:0;border-radius:50%;background:none;color:var(--muted);vertical-align:middle;cursor:pointer}
|
|
252
|
+
.rn-tw:hover{background:var(--hover);color:var(--ink)}.rn-tw[aria-expanded=true]{color:var(--ink)}.rn-tw[aria-expanded=true] svg{transform:rotate(90deg)}
|
|
253
|
+
.rn-kind{display:inline-block;margin-right:6px;padding:0 8px;border:1px solid color-mix(in srgb,var(--ink) 30%,transparent);border-radius:999px;font-size:11px;font-weight:600;letter-spacing:.06em;text-transform:uppercase;color:var(--muted);white-space:nowrap;vertical-align:middle}
|
|
254
|
+
.rn-res .rn-meter{display:inline-flex;width:84px;margin-right:10px;vertical-align:middle}
|
|
255
|
+
.rn-count{font-size:13px;font-weight:600;font-variant-numeric:tabular-nums}tr.bad .rn-count{color:var(--ko)}tr.busy .rn-count::after{content:" …"}
|
|
256
|
+
.res.on{color:var(--link);font-weight:600}
|
|
257
|
+
.rn-go{display:inline-grid;place-items:center;width:36px;height:30px;padding:0;border:1px solid var(--rule);border-radius:999px;background:var(--panel);color:var(--ink);cursor:pointer}
|
|
258
|
+
.rn-go:hover{border-color:var(--ink)}.rn-go[disabled]{opacity:.45;cursor:not-allowed}
|
|
259
|
+
table.rn tr.rn-more>td{padding:12px var(--bleed) 18px calc(var(--bleed) + 48px);background:var(--code)}.runner[data-scope] table.rn tr.rn-more>td{padding-left:calc(var(--bleed) + 24px)}
|
|
260
|
+
.rn-told{display:grid;grid-template-columns:repeat(auto-fit,minmax(300px,1fr));gap:14px 22px;align-items:start}
|
|
261
|
+
.rn-detail h4{margin:12px 0 4px;font-size:11.5px;font-weight:600;letter-spacing:.1em;text-transform:uppercase;color:var(--muted)}.rn-detail :is(.rn-told>div,.fail)>h4:first-child{margin-top:0}
|
|
262
|
+
.rn-detail p{margin:0 0 4px}.rn-detail .fail{margin:0 0 12px}.rn-detail .line{display:flex;margin-top:6px}
|
|
263
|
+
.rn-detail pre{margin:0 0 8px;padding:8px 12px;border-radius:8px;background:var(--panel);white-space:pre-wrap;overflow-wrap:anywhere;font-size:12.5px;line-height:1.5;max-height:320px;overflow:auto}
|
|
264
|
+
.rn-detail pre.rn-log{background:var(--log);color:var(--on-log);white-space:pre;overflow-wrap:normal;max-height:520px}
|
|
227
265
|
.tiles{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:12px;margin:26px 0 0}
|
|
228
266
|
.tile{background:var(--code);border-radius:12px;padding:16px 18px;color:var(--ink)}
|
|
229
267
|
.tile b{display:block;font:700 34px/1.15 var(--sans);font-variation-settings:var(--opsz);letter-spacing:-.03em;font-variant-numeric:tabular-nums}
|
|
@@ -244,4 +282,56 @@ dialog .bar{display:flex;justify-content:flex-end;gap:8px;margin-top:20px}
|
|
|
244
282
|
.io,.try .grid{grid-template-columns:minmax(0,1fr)}.io .arrow{display:none}
|
|
245
283
|
.filter{width:160px}
|
|
246
284
|
tr.run-row .runbox{position:sticky;left:0;width:calc(100vw - 40px)}
|
|
285
|
+
table.rn{min-width:0}.rn-res .rn-meter,table.rn .rn-time{display:none}
|
|
286
|
+
table.rn tr.rn-op>.rn-name{padding-left:calc(var(--bleed) + 10px)}table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 20px)}
|
|
287
|
+
.runner[data-scope] table.rn tr.rn-case>.rn-name{padding-left:calc(var(--bleed) + 10px)}
|
|
288
|
+
table.rn tr.rn-more>td,.runner[data-scope] table.rn tr.rn-more>td{padding-left:var(--bleed)}
|
|
289
|
+
.rn-told{grid-template-columns:minmax(0,1fr)}
|
|
247
290
|
}
|
|
291
|
+
|
|
292
|
+
/* Dependencies: two drawings, of the tokens above alone. An arc is ink, dashed where it only reads a state, and warm where it goes against the order. */
|
|
293
|
+
.dep-scroll{margin-top:14px;padding:6px var(--bleed)}
|
|
294
|
+
svg.dep{display:block;max-width:none;height:auto}
|
|
295
|
+
.dep-box{fill:var(--panel);stroke:var(--ink);stroke-width:1.1}
|
|
296
|
+
.dep-name{font:600 14px var(--sans);font-variation-settings:var(--opsz);fill:var(--ink)}
|
|
297
|
+
.dep-sub,.dep-count{font:12px var(--sans);font-variation-settings:var(--opsz);fill:var(--muted)}
|
|
298
|
+
.dep-word{font:12.5px var(--mono);fill:var(--ink)}
|
|
299
|
+
.dep-n{font:600 11.5px var(--mono);fill:var(--ink);paint-order:stroke;stroke:var(--bg);stroke-width:5px;stroke-linejoin:round}
|
|
300
|
+
.dep-hit{fill:transparent}
|
|
301
|
+
.dep a:hover{text-decoration:none}
|
|
302
|
+
.dep-row:hover .dep-hit,.dep-row:focus-visible .dep-hit,.dep-row.lit .dep-hit{fill:var(--hover)}
|
|
303
|
+
.dep-node.here .dep-box{stroke-width:2.4}
|
|
304
|
+
.dep-node:hover .dep-box,.dep-node:focus-visible .dep-box,.dep-node.lit .dep-box{fill:var(--run)}
|
|
305
|
+
.dep .wire{fill:none;stroke:var(--ink);stroke-width:1.2}
|
|
306
|
+
.dep .tip{fill:var(--ink)}
|
|
307
|
+
.dep-wire{opacity:.45}
|
|
308
|
+
.dep-arc.state .wire{stroke-dasharray:5 4}
|
|
309
|
+
.dep-arc.against .wire{stroke:var(--ko);stroke-width:1.8}
|
|
310
|
+
.dep-arc.against .tip,.dep-arc.against .dep-n{fill:var(--ko)}
|
|
311
|
+
.dep-arc:hover .wire,.dep-wire:hover .wire{stroke-width:2.2}
|
|
312
|
+
.dep-wire:hover{opacity:1}
|
|
313
|
+
.dep.lighting :is(.dep-arc,.dep-wire):not(.lit){opacity:.08}
|
|
314
|
+
.dep.lighting :is(.dep-arc,.dep-wire).lit{opacity:1}
|
|
315
|
+
.dep.lighting :is(.dep-node,.dep-row):not(.lit) text{opacity:.35}
|
|
316
|
+
.dep-legend{margin-top:10px;flex-direction:row;flex-wrap:wrap;gap:4px 22px}.dep-legend b{color:var(--ink);font-family:var(--mono);font-size:11.5px}
|
|
317
|
+
.dep-key{display:inline-block;width:26px;border-top:1.5px solid var(--ink);vertical-align:middle;margin-right:4px}
|
|
318
|
+
.dep-key.state{border-top-style:dashed}
|
|
319
|
+
.dep-key.against{border-top:2px solid var(--ko)}
|
|
320
|
+
.dep-box.here{stroke-width:2.4}
|
|
321
|
+
.dep-rule{stroke:var(--ink);stroke-width:1.1}
|
|
322
|
+
.dep-part{font:600 10.5px var(--sans);font-variation-settings:var(--opsz);letter-spacing:.08em;text-transform:uppercase;fill:var(--muted)}
|
|
323
|
+
.dep-wire.state .wire{stroke-dasharray:5 4}
|
|
324
|
+
.dep-wire.against .wire{stroke:var(--ko)}
|
|
325
|
+
.dep-wire.against .tip{fill:var(--ko)}
|
|
326
|
+
.dep-word.condition{font-family:var(--sans);font-variation-settings:var(--opsz);font-size:13px}
|
|
327
|
+
.dep-word.type{fill:var(--t-type)}
|
|
328
|
+
.dep-word.state{fill:var(--t-key)}
|
|
329
|
+
/* The one switch of the drawing of an area: which of the two is shown is decided here, with no script. */
|
|
330
|
+
.dep-switch{display:inline-flex;align-items:center;gap:10px;margin:14px 0 0;font-size:14px;cursor:pointer;user-select:none}
|
|
331
|
+
.dep-switch input{position:absolute;opacity:0;width:1px;height:1px}
|
|
332
|
+
.dep-knob{flex:none;position:relative;width:34px;height:20px;border-radius:999px;background:var(--rule)}
|
|
333
|
+
.dep-knob::after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--panel);box-shadow:0 0 0 1px var(--rule)}
|
|
334
|
+
.dep-switch input:checked+.dep-knob{background:var(--ink)}
|
|
335
|
+
.dep-switch input:checked+.dep-knob::after{transform:translateX(14px)}
|
|
336
|
+
.dep-switch input:focus-visible+.dep-knob{outline:2px solid var(--link);outline-offset:2px}
|
|
337
|
+
.dep-mode:has(.dep-detail-on:checked) .dep-plain,.dep-mode:not(:has(.dep-detail-on:checked)) .dep-detailed{display:none}
|
package/dist/explorer/telling.js
CHANGED
|
@@ -28,3 +28,5 @@ export function ranOf(operation, outcome, mode, secrets) {
|
|
|
28
28
|
const log = operationLines({ operation, outcomes: [told], gaps: [] }, 'trace').map((line) => hidden(plain(line), secrets)).filter((line, at) => at > 0 || line !== '');
|
|
29
29
|
return { result: resultOf(kept), mode, seconds: outcome.ms / 1000, background: outcome.kase.given.seed, request, answer: call ? { status: call.status, body: call.body } : null, failed: failures([...operation.clauses, ...outcome.kase.and], kept), log };
|
|
30
30
|
}
|
|
31
|
+
/** What a run decided of one case among many, as the page is told it while the others run: of the whole telling of that case, what says how it went. */
|
|
32
|
+
export const amongOf = (operation, kase, told) => ({ ref: idOf('case', kase.name), operation: operation.name, result: told.result, seconds: told.seconds, failed: told.failed });
|
package/dist/explorer/tests.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { RESULT, citizens, esc, link, list, plural, table } from './html.js';
|
|
2
2
|
import { answeredOf, areaTitle, callerOf, crumbs, sentOf } from './operation.js';
|
|
3
3
|
import { idOf } from './wiki.js';
|
|
4
|
-
|
|
4
|
+
/** A count of the run, in large: named for the script, which counts again as cases are run. */
|
|
5
|
+
const tile = (value, label, key, cls = '') => `<div class="tile ${cls}" data-tile="${key}"><b>${esc(value)}</b><span>${esc(label)}</span></div>`;
|
|
5
6
|
const seconds = (ms) => (ms === undefined ? '' : `<span class="m s">${(ms / 1000).toFixed(1)} s</span>`);
|
|
6
7
|
/** Of the cases of an operation, how many ran, passed, failed. */
|
|
7
8
|
function ledger(cases) {
|
|
@@ -15,27 +16,63 @@ export function resultOfAll(results) {
|
|
|
15
16
|
return 'failed';
|
|
16
17
|
return results.includes('passed') ? 'passed' : 'notrun';
|
|
17
18
|
}
|
|
19
|
+
/** How the cases of a row went, in words: what passed, what failed, what was not run. */
|
|
20
|
+
function wentOf(cases) {
|
|
21
|
+
const of = ledger(cases);
|
|
22
|
+
if (!of.ran)
|
|
23
|
+
return `${plural(of.notRun, 'case')}, not run`;
|
|
24
|
+
return [`${of.passed} passed`, ...(of.failed ? [`${of.failed} failed`] : []), ...(of.notRun ? [`${of.notRun} not run`] : [])].join(', ');
|
|
25
|
+
}
|
|
26
|
+
const timeOf = (cases) => seconds(cases.some((one) => one.ms !== undefined) ? cases.reduce((sum, one) => sum + (one.ms ?? 0), 0) : undefined);
|
|
27
|
+
const kindOf = (kase) => (kase.generated ? 'from a condition' : kase.kind);
|
|
28
|
+
/** A row that holds others: an area, or an operation, with how its cases went. What is said beside its name ends with the way to its page of the tests. */
|
|
29
|
+
function groupRow(cls, ref, within, name, sub, cases) {
|
|
30
|
+
return `<tr class="${cls}" data-ref="${esc(ref)}"${within ? ` data-in="${esc(within)}"` : ''}><th scope="row" class="rn-name"><span class="rn-what">${name}</span> <span class="m s">${sub}</span></th><td class="rn-res">${esc(wentOf(cases))}</td><td class="rn-time">${timeOf(cases)}</td></tr>`;
|
|
31
|
+
}
|
|
32
|
+
/** A case, as the last run left it; and under it, when it failed, what did not hold. */
|
|
33
|
+
function caseRow(kase, within) {
|
|
34
|
+
const ref = idOf('case', kase.name);
|
|
35
|
+
const failed = kase.findings.length ? ` data-failed="${esc(JSON.stringify(kase.findings))}"` : '';
|
|
36
|
+
const row = `<tr class="rn-case" data-ref="${esc(ref)}" data-in="${esc(within)}" data-result="${kase.result}"${kase.ms === undefined ? '' : ` data-ms="${kase.ms}"`}${failed}><td class="rn-name"><span class="rn-kind">${kindOf(kase)}</span> <span class="rn-what">${link(`#${ref}`, kase.description)}</span>${kase.for ? ` <span class="m s">for: ${esc(kase.for)}</span>` : ''}</td><td class="rn-res">${RESULT[kase.result]}</td><td class="rn-time">${seconds(kase.ms)}</td></tr>`;
|
|
37
|
+
const more = kase.findings.length ? `<tr class="rn-more" data-of="${esc(ref)}"><td colspan="3"><div class="fail">${list(kase.findings.map(esc))}</div></td></tr>` : '';
|
|
38
|
+
return row + more;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The runner: every case of some areas, by area and by operation, a row each, with what the last
|
|
42
|
+
* run decided of it. Of one area alone, its operations are the first level, and `scope` names the
|
|
43
|
+
* area as a run is asked of it. The script adds what runs and what folds; without it every row is
|
|
44
|
+
* there to read, and what did not hold is under its case.
|
|
45
|
+
*/
|
|
46
|
+
function runner(areas, scope) {
|
|
47
|
+
const rows = areas.map((area) => {
|
|
48
|
+
const within = idOf('area', area.name);
|
|
49
|
+
const head = scope === undefined ? groupRow('rn-area', within, undefined, esc(areaTitle(area.name)), `${plural(area.operations.length, 'operation')} · ${plural(area.operations.flatMap((one) => one.cases).length, 'case')} · ${link(`#${idOf('test-area', area.name)}`, 'its page')}`, area.operations.flatMap((one) => one.cases)) : '';
|
|
50
|
+
const operations = area.operations.map((operation) => {
|
|
51
|
+
const ref = idOf('op', operation.name);
|
|
52
|
+
const sub = `${esc(operation.agent)} · ${esc(`${operation.entry.method} ${operation.entry.path}`)}${operation.observes ? ' · an observation' : ''} · ${link(`#${idOf('test', operation.name)}`, 'its page')}`;
|
|
53
|
+
return groupRow('rn-op', ref, scope === undefined ? within : undefined, `<span class="mono">${esc(operation.name)}</span>`, sub, operation.cases) + operation.cases.map((kase) => caseRow(kase, ref)).join('');
|
|
54
|
+
});
|
|
55
|
+
return head + operations.join('');
|
|
56
|
+
});
|
|
57
|
+
const place = scope === undefined ? '' : ` data-scope="${esc(idOf('area', scope))}" data-area="${esc(scope)}"`;
|
|
58
|
+
return `<div class="runner"${place}><div class="rn-bar work"></div><div class="scroll"><table class="rn"><thead><tr><th>${scope === undefined ? 'Area, operation, case' : 'Operation, case'}</th><th>Result</th><th class="rn-time">Time</th></tr></thead><tbody>${rows.join('')}</tbody></table></div></div>`;
|
|
59
|
+
}
|
|
18
60
|
function overviewPage(wiki) {
|
|
19
61
|
const run = wiki.run;
|
|
62
|
+
const all = wiki.operations.flatMap((one) => one.cases);
|
|
63
|
+
const of = ledger(all);
|
|
64
|
+
const tiles = `<div class="tiles">${tile(of.ran, 'cases run', 'ran')}${tile(of.passed, 'passing', 'passed', 'ok')}${tile(of.failed, 'failing', 'failed', of.failed ? 'ko' : 'ok')}${tile(of.notRun, 'not run', 'notrun')}</div>`;
|
|
65
|
+
const table = runner(performing(wiki));
|
|
20
66
|
if (!run) {
|
|
21
|
-
const body = `<h1>Tests</h1><p class="lead">No run of this specification is known. A run writes its report beside the console (<span class="mono">--report=</span>), and the explorer shows its results here.</p
|
|
67
|
+
const body = `<h1>Tests</h1><p class="lead">No run of this specification is known. A run writes its report beside the console (<span class="mono">--report=</span>), and the explorer shows its results here.</p>${tiles}${table}`;
|
|
22
68
|
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
23
69
|
}
|
|
24
|
-
const failing = wiki.operations.filter((one) => one.cases.some((kase) => kase.result === 'failed'));
|
|
25
|
-
const failures = failing
|
|
26
|
-
.map((one) => `<h3>${link(`#${idOf('test', one.name)}`, one.name)}</h3>${list(one.cases.filter((kase) => kase.result === 'failed').map((kase) => `${esc(kase.description)}${kase.findings.length ? `<div class="fail">${list(kase.findings.map(esc))}</div>` : ''}`))}`)
|
|
27
|
-
.join('');
|
|
28
|
-
const rows = performing(wiki).map((area) => {
|
|
29
|
-
const of = ledger(area.operations.flatMap((one) => one.cases));
|
|
30
|
-
return [link(`#${idOf('test-area', area.name)}`, areaTitle(area.name)), String(of.passed), String(of.failed), String(of.notRun), RESULT[resultOfAll(area.operations.map((one) => one.result))]];
|
|
31
|
-
});
|
|
32
70
|
const narrowed = run.narrowed.length ? `Asked: <span class="mono">${esc(run.narrowed.join(' '))}</span>. The rest was not run.` : 'The whole suite.';
|
|
33
71
|
const body = `<h1>Tests</h1>
|
|
34
72
|
<p class="lead">Run ${esc(new Date(run.when).toLocaleString('en-GB'))}${run.fast ? ', the fast run' : ''}${run.stopped ? ', stopped at the first failure' : ''}.</p>
|
|
35
|
-
|
|
73
|
+
${tiles}
|
|
36
74
|
<p class="sub">${narrowed}</p>
|
|
37
|
-
|
|
38
|
-
<h2>By area</h2>${table(['Area', 'Passed', 'Failed', 'Not run', 'Result'], rows)}`;
|
|
75
|
+
${table}`;
|
|
39
76
|
return { id: 'tests', kind: 'Tests', title: 'Tests', body };
|
|
40
77
|
}
|
|
41
78
|
/**
|
|
@@ -62,12 +99,8 @@ function operationPage(operation, refs) {
|
|
|
62
99
|
return { id: idOf('test', operation.name), kind: 'Tests', title: `${operation.name} · tests`, nav: 'tests', body };
|
|
63
100
|
}
|
|
64
101
|
function areaPage(area) {
|
|
65
|
-
const rows = area.operations.map((one) => {
|
|
66
|
-
const of = ledger(one.cases);
|
|
67
|
-
return [link(`#${idOf('test', one.name)}`, one.name), String(of.passed), String(of.failed), String(of.notRun), RESULT[one.result]];
|
|
68
|
-
});
|
|
69
102
|
const body = `${crumbs(link('#tests', 'Tests'))}<h1>${esc(areaTitle(area.name))}</h1>
|
|
70
|
-
${
|
|
103
|
+
${runner([area], area.name)}`;
|
|
71
104
|
return { id: idOf('test-area', area.name), kind: 'Tests', title: `${areaTitle(area.name)} · tests`, nav: 'tests', body };
|
|
72
105
|
}
|
|
73
106
|
/** The areas that have something to run: one that holds words only has no test. */
|
package/dist/explorer/wiki.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
import { addressOf } from '../addresses.js';
|
|
7
7
|
import { casesOf, gapsOf } from '../planning.js';
|
|
8
8
|
import { named, sameSentence } from '../suite.js';
|
|
9
|
+
import { dependenciesOf } from './depending.js';
|
|
9
10
|
import { refsOf } from './elo.js';
|
|
10
11
|
/** A name, made safe for an anchor, as the suite is read to have no two at one (addresses.ts); and the anchor of a citizen of a kind: `predicate-seesBoard`. */
|
|
11
12
|
export const slug = addressOf;
|
|
@@ -68,6 +69,7 @@ function typeKindsOf(model, operations) {
|
|
|
68
69
|
export function wikiOf(suite, report) {
|
|
69
70
|
const { model } = suite;
|
|
70
71
|
const operations = suite.operations.map((operation) => operationView(operation, suite, report)).sort((a, b) => a.area.localeCompare(b.area) || a.name.localeCompare(b.name));
|
|
72
|
+
const refs = refsOf(model);
|
|
71
73
|
return {
|
|
72
74
|
system: model.system,
|
|
73
75
|
descriptions: model.descriptions,
|
|
@@ -80,9 +82,10 @@ export function wikiOf(suite, report) {
|
|
|
80
82
|
state: model.state,
|
|
81
83
|
types: model.types,
|
|
82
84
|
worldKeys: Object.keys(model.world),
|
|
83
|
-
refs
|
|
85
|
+
refs,
|
|
84
86
|
run: report ? runOf(report, operations) : null,
|
|
85
87
|
typeKinds: typeKindsOf(model, suite.operations),
|
|
88
|
+
dependencies: dependenciesOf(model, suite.operations, refs),
|
|
86
89
|
};
|
|
87
90
|
}
|
|
88
91
|
/** The counterexamples that violate a precondition: those that are "for" its sentence. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@enspirit/opspicy",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Specifies the operations of a system by their clauses, as sentences that Elo gives a meaning, and runs them black-box",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,8 @@
|
|
|
38
38
|
"test:package": "node --test --test-reporter=spec \"test/package/*.test.ts\"",
|
|
39
39
|
"build": "node build.ts",
|
|
40
40
|
"prepack": "npm run build",
|
|
41
|
-
"example": "node example/splitter.ts"
|
|
41
|
+
"example": "node example/splitter.ts",
|
|
42
|
+
"training": "node example/training.ts"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
45
|
"@enspirit/elo": "1.2.4",
|