diff --git a/app/assets/css/main.css b/app/assets/css/main.css index 521b59c..3893c71 100644 --- a/app/assets/css/main.css +++ b/app/assets/css/main.css @@ -6082,3 +6082,194 @@ button.tile:hover { white-space: pre; pointer-events: none; } + +/* Test bench */ +.node .bench-body { + fill: #141c24; + stroke: #3b4554; + stroke-dasharray: 4 3; +} + +.node .bench-body.pass { + stroke: var(--on); + stroke-dasharray: none; +} + +.node .bench-body.fail { + stroke: var(--danger); + stroke-dasharray: none; +} + +.node .bench-title { + fill: var(--text); + font-size: 10px; + font-weight: 600; + pointer-events: none; +} + +.node .bench-line { + fill: var(--muted); + font-size: 10px; + pointer-events: none; +} + +.node .bench-line.pass { + fill: var(--on); +} + +.node .bench-line.fail { + fill: var(--danger); +} + +.modal.bench { + width: min(1100px, 100%); +} + +.modal.bench code { + font-family: var(--font-mono); + font-size: 11px; + color: var(--text); +} + +.bench-bar { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: 6px; + margin: 10px 0 8px; +} + +.bench-target { + display: flex; + align-items: center; + gap: 8px; + font-size: 13px; + font-weight: 600; +} + +.bench-summary { + margin-bottom: 6px; + font-size: 13px; + font-weight: 600; +} + +.bench-summary.pass { + color: var(--on); +} + +.bench-summary.fail { + color: var(--danger); +} + +.bench-table-wrap { + max-height: 55vh; + overflow: auto; + border: 1px solid var(--border); + border-radius: 6px; +} + +.bench-table { + border-collapse: collapse; + font-size: 12px; +} + +.bench-table th { + position: sticky; + top: 0; + z-index: 1; + padding: 4px 4px; + background: var(--panel); + color: var(--muted); + font-weight: 600; + text-align: left; + white-space: nowrap; +} + +.bench-table th small { + margin-left: 2px; + font-size: 9px; + opacity: 0.7; +} + +.bench-table th.out, +.bench-table td.out { + background: rgb(61 220 132 / 0.04); +} + +.bench-table td { + position: relative; + padding: 1px 3px; + border-top: 1px solid rgb(37 46 58 / 0.6); + vertical-align: middle; +} + +.bench-table tr.fail td { + background: rgb(255 107 107 / 0.06); +} + +.bench-num { + width: 32px; + color: var(--muted); + text-align: right; +} + +.bench-arrow { + width: 22px; + text-align: center; + color: var(--muted); +} + +.bench-cell { + width: 64px; + padding: 3px 5px; + background: transparent; + border: 1px solid transparent; + border-radius: 4px; + font-family: var(--font-mono); + font-size: 12px; +} + +.bench-cell:hover { + border-color: var(--border); +} + +.bench-cell:focus { + border-color: var(--accent); + background: var(--panel-2); + outline: none; +} + +.bench-cell::placeholder { + color: #4a5566; +} + +.bench-got { + display: block; + padding: 0 5px 2px; + color: var(--danger); + font-family: var(--font-mono); + font-size: 10px; +} + +.bench-actions { + white-space: nowrap; + text-align: right; +} + +.bench-err { + display: inline-block; + max-width: 240px; + overflow: hidden; + text-overflow: ellipsis; + vertical-align: middle; + color: var(--danger); + font-size: 11px; +} + +.bench-add { + margin-top: 8px; +} + +.bench-empty { + margin-top: 12px; +} diff --git a/app/components/editor/App.vue b/app/components/editor/App.vue index 3f92961..90452c6 100644 --- a/app/components/editor/App.vue +++ b/app/components/editor/App.vue @@ -86,5 +86,6 @@ watch( + diff --git a/app/components/editor/BenchDialog.vue b/app/components/editor/BenchDialog.vue new file mode 100644 index 0000000..402942a --- /dev/null +++ b/app/components/editor/BenchDialog.vue @@ -0,0 +1,164 @@ + + + diff --git a/app/components/editor/Canvas.vue b/app/components/editor/Canvas.vue index d570d1a..ce143d6 100644 --- a/app/components/editor/Canvas.vue +++ b/app/components/editor/Canvas.vue @@ -1247,6 +1247,7 @@ function onPointerUp(e: PointerEvent) { function onDoubleClick(node: CircuitNode) { if (node.kind === 'chip' && node.chip) ed.open(node.chip) + else if (node.kind === 'bench') ed.benchOpen.value = node.id else if (['input', 'output', 'lamp', 'button', 'note', 'hex', 'panel', 'outpanel', 'tag', 'ref'].includes(node.kind)) { ed.selection.value = [node.id] ed.labelFocus.value++ @@ -1281,6 +1282,7 @@ function nudge(dx: number, dy: number) { function onKey(e: KeyboardEvent) { const el = e.target as HTMLElement if (el.closest?.('input, textarea, select, [contenteditable]')) return + if (ed.benchOpen.value) return if (ed.dialog.value || ed.showHelp.value) { if (e.key === 'Escape') { ed.dialog.value = null diff --git a/app/components/editor/NodeView.vue b/app/components/editor/NodeView.vue index f1b94b0..eb0d3e7 100644 --- a/app/components/editor/NodeView.vue +++ b/app/components/editor/NodeView.vue @@ -172,6 +172,21 @@ const faceHex = (inner: string) => sevenSegment([0, 1, 2, 3].reduce((n, i) => n /** The colour of an RGB pixel inside this chip ('' while off). */ const facePx = (inner: string) => rgbHex(fv(inner, 'r'), fv(inner, 'g'), fv(inner, 'b')) const rgbNow = computed(() => (props.node.rgb ? rgbHex(v('r'), v('g'), v('b')) : '')) +// Test bench: its target and the last run. +const benchSum = computed(() => { + if (props.node.kind !== 'bench') return { title: '', line: '', state: '' } + const target = ed.benchTarget(props.node) + const title = target ? `Tests: ${target.def.name}` : 'Test bench' + const rows = props.node.bench?.rows.length ?? 0 + const r = props.ghost ? undefined : ed.benchResults.value.get(props.node.id) + if (!target) return { title, line: 'drop on a component', state: 'idle' } + if (!rows) return { title, line: 'no tests yet: double-click', state: 'idle' } + if (!r) return { title, line: `${rows} tests`, state: 'idle' } + if (r.error && !r.fail) return { title, line: r.error, state: 'fail' } + if (r.fail) return { title, line: `✗ ${r.fail} failing, ${r.pass} pass`, state: 'fail' } + return { title, line: r.pass ? `✓ all ${r.pass} pass` : `${rows} rows, nothing checked`, state: r.pass ? 'pass' : 'idle' } +}) + // Terminal and keyboard: what the store keeps for this part. const TERM_CHAR = 6.6 const termLines = computed(() => { @@ -421,6 +436,13 @@ const title = computed(() => { {{ node.conn && !connType ? 'type missing' : 'no lines' }} + + +