Applies the byRegexp(\\.min$ | \\.max$) → custom.lineStyle dashed pattern to all 4 timeseries panels in config/machine.json — pattern confirmed via S2 spike (#33). Forward-compatible: nodes that don't yet emit .min/.max fields see no change in rendering (regex won't match). - config/machine.json: 4 timeseries panels gain byRegexp overrides for both .min$ and .max$, dashed [10,10], orange (min) / red (max). - test/basic/slice38-dashed-bounds.basic.test.js: 2 cases (presence per ts panel, anchor-to-end forward compatibility). Companion-field emission helper (generalFunctions.outputUtils — produces <field>, <field>.min, <field>.max from a bounds-aware source) is a generalFunctions submodule change and lands in a follow-up PR — out of scope for this dashboardAPI-only slice. Closes #38
44 lines
1.9 KiB
JavaScript
44 lines
1.9 KiB
JavaScript
'use strict';
|
|
|
|
const test = require('node:test');
|
|
const assert = require('node:assert/strict');
|
|
|
|
const DashboardApi = require('../../src/specificClass.js');
|
|
|
|
test('rotatingMachine template carries byRegexp dashed overrides for .min/.max', () => {
|
|
const api = new DashboardApi({});
|
|
const dash = api.loadTemplate('machine');
|
|
const ts = dash.panels.filter((p) => p.type === 'timeseries');
|
|
assert.ok(ts.length >= 1, 'has at least one timeseries panel');
|
|
|
|
for (const panel of ts) {
|
|
const overrides = panel?.fieldConfig?.overrides || [];
|
|
const minOv = overrides.find(
|
|
(o) => o.matcher?.id === 'byRegexp' && /\.min\$/.test(o.matcher?.options || '')
|
|
);
|
|
const maxOv = overrides.find(
|
|
(o) => o.matcher?.id === 'byRegexp' && /\.max\$/.test(o.matcher?.options || '')
|
|
);
|
|
assert.ok(minOv, `panel "${panel.title}" missing .min override`);
|
|
assert.ok(maxOv, `panel "${panel.title}" missing .max override`);
|
|
|
|
const lineStyle = minOv.properties.find((p) => p.id === 'custom.lineStyle');
|
|
assert.equal(lineStyle?.value?.fill, 'dash', '.min override sets dashed lineStyle');
|
|
assert.deepEqual(lineStyle?.value?.dash, [10, 10], '.min override sets dash pattern [10,10]');
|
|
}
|
|
});
|
|
|
|
test('dashed overrides are forward-compatible: no effect when fields absent', () => {
|
|
// The byRegexp matcher only affects series whose name ends in .min/.max.
|
|
// When the node doesn't emit those fields, the override has no effect on
|
|
// the rendered panel — series simply don't appear. Verified by the
|
|
// matcher pattern being a strict regex.
|
|
const api = new DashboardApi({});
|
|
const dash = api.loadTemplate('machine');
|
|
const ts = dash.panels.filter((p) => p.type === 'timeseries')[0];
|
|
const minOv = ts.fieldConfig.overrides.find(
|
|
(o) => o.matcher?.id === 'byRegexp' && /\.min\$/.test(o.matcher.options || '')
|
|
);
|
|
assert.match(minOv.matcher.options, /\$$/, 'matcher anchored to end of name');
|
|
});
|