test: rewire integration test to renamed 02-Dashboard.json
Example flows were renamed to the numbered-tier convention (02-Dashboard.json). The integration test still loaded the old basic-dashboard.flow.json and asserted the old 6-output parser shape + raw-number payloads. Update both the filename and the assertions to match the current 14-output fn_status_split (topic labels like 'Level', payload strings like '3.25 m'). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,7 +4,7 @@ const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
|
||||
function loadDashboardFlow() {
|
||||
const flowPath = path.join(__dirname, '../../examples/basic-dashboard.flow.json');
|
||||
const flowPath = path.join(__dirname, '../../examples/02-Dashboard.json');
|
||||
return JSON.parse(fs.readFileSync(flowPath, 'utf8'));
|
||||
}
|
||||
|
||||
@@ -22,27 +22,29 @@ function makeContextStub() {
|
||||
|
||||
test('basic dashboard flow contains the pumpingStation node and trend widgets', () => {
|
||||
const flow = loadDashboardFlow();
|
||||
const ps = flow.find((n) => n.id === 'ps_node_basic');
|
||||
const parser = flow.find((n) => n.id === 'ps_parse_output');
|
||||
const levelChart = flow.find((n) => n.id === 'ps_chart_level');
|
||||
const demandChart = flow.find((n) => n.id === 'ps_chart_demand');
|
||||
const ps = flow.find((n) => n.type === 'pumpingStation');
|
||||
const parser = flow.find((n) => n.id === 'fn_status_split');
|
||||
const levelChart = flow.find((n) => n.id === 'ui_chart_level');
|
||||
const volumeChart = flow.find((n) => n.id === 'ui_chart_volume');
|
||||
const flowChart = flow.find((n) => n.id === 'ui_chart_flow');
|
||||
|
||||
assert.ok(ps, 'ps_node_basic should exist');
|
||||
assert.ok(ps, 'pumpingStation node should exist');
|
||||
assert.equal(ps.type, 'pumpingStation');
|
||||
assert.equal(ps.controlMode, 'levelbased');
|
||||
assert.equal(ps.levelCurveType, 'linear');
|
||||
assert.equal(ps.inletPipeDiameter, 0.4);
|
||||
assert.equal(ps.inletPipeDiameter, 0.3);
|
||||
assert.equal(ps.outletPipeDiameter, 0.3);
|
||||
assert.ok(parser, 'ps_parse_output should exist');
|
||||
assert.equal(parser.outputs, 6);
|
||||
assert.ok(parser, 'fn_status_split should exist');
|
||||
assert.equal(parser.outputs, 14);
|
||||
assert.equal(levelChart.type, 'ui-chart');
|
||||
assert.equal(demandChart.type, 'ui-chart');
|
||||
assert.equal(volumeChart.type, 'ui-chart');
|
||||
assert.equal(flowChart.type, 'ui-chart');
|
||||
});
|
||||
|
||||
test('basic dashboard parser routes process fields to charts and state text', () => {
|
||||
const flow = loadDashboardFlow();
|
||||
const parser = flow.find((n) => n.id === 'ps_parse_output');
|
||||
assert.ok(parser, 'ps_parse_output should exist');
|
||||
const parser = flow.find((n) => n.id === 'fn_status_split');
|
||||
assert.ok(parser, 'fn_status_split should exist');
|
||||
|
||||
const func = new Function('msg', 'context', 'node', parser.func);
|
||||
const context = makeContextStub();
|
||||
@@ -56,8 +58,12 @@ test('basic dashboard parser routes process fields to charts and state text', ()
|
||||
payload: {
|
||||
'level.predicted.atequipment.default': 3.25,
|
||||
'volume.predicted.atequipment.default': 32.5,
|
||||
'volumePercent.predicted.atequipment.default': 65,
|
||||
'flow.predicted.in.default': 0.005,
|
||||
'flow.predicted.out.default': 0.002,
|
||||
'netFlowRate.predicted.atequipment.default': 0.003,
|
||||
percControl: 25,
|
||||
mode: 'levelbased',
|
||||
direction: 'filling',
|
||||
safetyState: 'normal',
|
||||
isOverflowing: false,
|
||||
@@ -66,22 +72,25 @@ test('basic dashboard parser routes process fields to charts and state text', ()
|
||||
}, context, node);
|
||||
|
||||
assert.ok(Array.isArray(out));
|
||||
assert.equal(out.length, 6);
|
||||
assert.equal(out[0].topic, 'level');
|
||||
assert.equal(out[0].payload, 3.25);
|
||||
assert.equal(out[1].topic, 'volume');
|
||||
assert.equal(out[1].payload, 32.5);
|
||||
assert.equal(out[2].topic, 'demand');
|
||||
assert.equal(out[2].payload, 25);
|
||||
assert.equal(out[3].topic, 'net_flow');
|
||||
assert.equal(out[3].payload, 0.003);
|
||||
assert.match(out[4].payload, /normal/);
|
||||
assert.match(out[5].payload, /level=3.25 m/);
|
||||
assert.equal(out.length, 14);
|
||||
assert.equal(out[0].payload, 'levelbased');
|
||||
assert.equal(out[1].payload, 'filling');
|
||||
assert.equal(out[2].payload, '3.25 m');
|
||||
assert.equal(out[3].payload, '32.50 m³');
|
||||
assert.equal(out[4].payload, '65.00 %');
|
||||
assert.equal(out[5].payload, '25.0 %');
|
||||
assert.deepEqual(out[7], { topic: 'Level', payload: 3.25 });
|
||||
assert.deepEqual(out[8], { topic: 'Volume', payload: 32.5 });
|
||||
assert.deepEqual(out[9], { topic: 'Volume %', payload: 65 });
|
||||
assert.deepEqual(out[10], { topic: 'Inflow', payload: 18 });
|
||||
assert.deepEqual(out[11], { topic: 'Outflow', payload: 7.2 });
|
||||
assert.deepEqual(out[12], { topic: 'Net', payload: 10.8 });
|
||||
assert.ok(Array.isArray(out[13].payload));
|
||||
});
|
||||
|
||||
test('basic dashboard parser keeps previous values when process output sends only changed fields', () => {
|
||||
const flow = loadDashboardFlow();
|
||||
const parser = flow.find((n) => n.id === 'ps_parse_output');
|
||||
const parser = flow.find((n) => n.id === 'fn_status_split');
|
||||
const func = new Function('msg', 'context', 'node', parser.func);
|
||||
const context = makeContextStub();
|
||||
const node = { send() {} };
|
||||
@@ -89,6 +98,6 @@ test('basic dashboard parser keeps previous values when process output sends onl
|
||||
func({ payload: { 'level.predicted.atequipment.default': 3.1, percControl: 10 } }, context, node);
|
||||
const out = func({ payload: { percControl: 20 } }, context, node);
|
||||
|
||||
assert.equal(out[0].payload, 3.1);
|
||||
assert.equal(out[2].payload, 20);
|
||||
assert.equal(out[2].payload, '3.10 m');
|
||||
assert.equal(out[5].payload, '20.0 %');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user