Pannello visione: la tabella quote mostra description invece di #id
Refs #114 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019A9CSrh9rfM5WwqKtg8BSE
This commit is contained in:
@@ -254,7 +254,8 @@ function visionExecute() {
|
|||||||
return ((this.result && this.result.measurements) || []).map((m) => {
|
return ((this.result && this.result.measurements) || []).map((m) => {
|
||||||
const st = subs.find((s) => s.id === m.subtask_id) || {};
|
const st = subs.find((s) => s.id === m.subtask_id) || {};
|
||||||
return {
|
return {
|
||||||
label: (st.marker_number ? st.marker_number + '. ' : '') + (st.measurement_type || st.name || '#' + m.subtask_id),
|
// #114: il nome della quota e' description (prima: measurement_type/name, che per le quote DXF e' vuoto -> '#15')
|
||||||
|
label: (st.marker_number ? st.marker_number + '. ' : '') + (st.description || st.measurement_type || '#' + m.subtask_id),
|
||||||
value: m.value,
|
value: m.value,
|
||||||
unit: st.unit || 'mm',
|
unit: st.unit || 'mm',
|
||||||
status: m.pass_fail,
|
status: m.pass_fail,
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
/**
|
||||||
|
* #114: etichette della tabella quote nel pannello visione (getter `rows`), con plain node.
|
||||||
|
*
|
||||||
|
* Run from src/frontend/flask_app: node tests/js/test_vision_rows.js
|
||||||
|
*/
|
||||||
|
'use strict';
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const vm = require('vm');
|
||||||
|
|
||||||
|
const src = fs.readFileSync(
|
||||||
|
path.join(__dirname, '..', '..', 'static', 'js', 'vision_execute.js'), 'utf8',
|
||||||
|
);
|
||||||
|
// Contesto vm con window e document finti; il file definisce visionExecute() globale
|
||||||
|
const win = {};
|
||||||
|
const ctx = vm.createContext({ window: win, document: { addEventListener() {}, querySelector() { return null; } } });
|
||||||
|
vm.runInContext(src + ';this.visionExecute = visionExecute;', ctx);
|
||||||
|
|
||||||
|
let failures = 0;
|
||||||
|
function check(label, cond, extra) {
|
||||||
|
if (cond) console.log('ok - ' + label);
|
||||||
|
else { failures++; console.log('FAIL - ' + label + (extra ? ' :: ' + extra : '')); }
|
||||||
|
}
|
||||||
|
|
||||||
|
win.__visionCfg = {
|
||||||
|
subtasks: [
|
||||||
|
{ id: 15, marker_number: 1, description: 'Larghezza', measurement_type: null, unit: 'mm' },
|
||||||
|
{ id: 16, marker_number: 2, description: '', measurement_type: 'Diametro', unit: 'mm' },
|
||||||
|
{ id: 17, marker_number: 3, description: null, measurement_type: null },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const comp = ctx.visionExecute();
|
||||||
|
comp.result = {
|
||||||
|
measurements: [
|
||||||
|
{ subtask_id: 15, value: 1, pass_fail: 'pass' },
|
||||||
|
{ subtask_id: 16, value: 2, pass_fail: 'pass' },
|
||||||
|
{ subtask_id: 17, value: 3, pass_fail: 'fail' },
|
||||||
|
{ subtask_id: 99, value: 4, pass_fail: 'pass' },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
const rows = comp.rows;
|
||||||
|
check('#114 riga 15: description', rows[0].label === '1. Larghezza', rows[0].label);
|
||||||
|
check('#114 riga 16: ripiego su measurement_type', rows[1].label === '2. Diametro', rows[1].label);
|
||||||
|
check('#114 riga 17: ripiego su #id', rows[2].label === '3. #17', rows[2].label);
|
||||||
|
check('#114 riga 99: subtask sconosciuta', rows[3].label === '#99', rows[3].label);
|
||||||
|
check('#114 unit riga 17 = mm', rows[2].unit === 'mm', rows[2].unit);
|
||||||
|
check('#114 unit riga 99 = mm', rows[3].unit === 'mm', rows[3].unit);
|
||||||
|
|
||||||
|
process.exit(failures ? 1 : 0);
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
"""Runs the plain-node vision panel quote rows label test (tests/js/test_vision_rows.js).
|
||||||
|
|
||||||
|
Same thin pytest wrapper pattern as test_dxf_zoom_js.py: shells out to
|
||||||
|
``node`` and asserts the script's own exit code. Skips (does not fail) when
|
||||||
|
node is not installed.
|
||||||
|
|
||||||
|
Covers gitea:Adriano/TieMeasureFlow#114.
|
||||||
|
"""
|
||||||
|
import shutil
|
||||||
|
import subprocess
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
FLASK_APP_DIR = Path(__file__).resolve().parent.parent
|
||||||
|
JS_TEST = Path(__file__).resolve().parent / "js" / "test_vision_rows.js"
|
||||||
|
|
||||||
|
|
||||||
|
def test_vision_rows_js_behaviour():
|
||||||
|
node = shutil.which("node")
|
||||||
|
if not node:
|
||||||
|
pytest.skip("node non installato: test JS delle etichette quote saltato")
|
||||||
|
|
||||||
|
result = subprocess.run(
|
||||||
|
[node, str(JS_TEST)],
|
||||||
|
cwd=str(FLASK_APP_DIR),
|
||||||
|
capture_output=True,
|
||||||
|
text=True,
|
||||||
|
timeout=30,
|
||||||
|
)
|
||||||
|
|
||||||
|
assert result.returncode == 0, (
|
||||||
|
f"tests/js/test_vision_rows.js fallito (exit {result.returncode})\n"
|
||||||
|
f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user