From ee38c8b5813cd700816bec2cedaad1f360d4bce6 Mon Sep 17 00:00:00 2001 From: znetsixe <73483679+znetsixe@users.noreply.github.com> Date: Thu, 19 Feb 2026 17:38:05 +0100 Subject: [PATCH] before functional changes by codex --- examples/README.md | 8 +++++++ examples/basic.flow.json | 6 +++++ examples/edge.flow.json | 6 +++++ examples/integration.flow.json | 6 +++++ package.json | 4 ++-- test/README.md | 12 ++++++++++ test/basic/.gitkeep | 0 .../basic/structure-module-load.basic.test.js | 8 +++++++ test/edge/.gitkeep | 0 .../structure-examples-node-type.edge.test.js | 11 +++++++++ test/helpers/.gitkeep | 0 test/integration/.gitkeep | 0 .../structure-examples.integration.test.js | 23 +++++++++++++++++++ 13 files changed, 82 insertions(+), 2 deletions(-) create mode 100644 examples/README.md create mode 100644 examples/basic.flow.json create mode 100644 examples/edge.flow.json create mode 100644 examples/integration.flow.json create mode 100644 test/README.md create mode 100644 test/basic/.gitkeep create mode 100644 test/basic/structure-module-load.basic.test.js create mode 100644 test/edge/.gitkeep create mode 100644 test/edge/structure-examples-node-type.edge.test.js create mode 100644 test/helpers/.gitkeep create mode 100644 test/integration/.gitkeep create mode 100644 test/integration/structure-examples.integration.test.js diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..f94a51a --- /dev/null +++ b/examples/README.md @@ -0,0 +1,8 @@ +# machineGroupControl Example Flows + +Import-ready Node-RED examples for machineGroupControl. + +## Files +- basic.flow.json +- integration.flow.json +- edge.flow.json diff --git a/examples/basic.flow.json b/examples/basic.flow.json new file mode 100644 index 0000000..ad5b77f --- /dev/null +++ b/examples/basic.flow.json @@ -0,0 +1,6 @@ +[ + {"id":"machineGroupControl_basic_tab","type":"tab","label":"machineGroupControl basic","disabled":false,"info":"machineGroupControl basic example"}, + {"id":"machineGroupControl_basic_node","type":"machineGroupControl","z":"machineGroupControl_basic_tab","name":"machineGroupControl basic","x":420,"y":180,"wires":[["machineGroupControl_basic_dbg"]]}, + {"id":"machineGroupControl_basic_inj","type":"inject","z":"machineGroupControl_basic_tab","name":"basic trigger","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"ping","payload":"1","payloadType":"str","x":160,"y":180,"wires":[["machineGroupControl_basic_node"]]}, + {"id":"machineGroupControl_basic_dbg","type":"debug","z":"machineGroupControl_basic_tab","name":"machineGroupControl basic debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":180,"wires":[]} +] diff --git a/examples/edge.flow.json b/examples/edge.flow.json new file mode 100644 index 0000000..3f7839d --- /dev/null +++ b/examples/edge.flow.json @@ -0,0 +1,6 @@ +[ + {"id":"machineGroupControl_edge_tab","type":"tab","label":"machineGroupControl edge","disabled":false,"info":"machineGroupControl edge example"}, + {"id":"machineGroupControl_edge_node","type":"machineGroupControl","z":"machineGroupControl_edge_tab","name":"machineGroupControl edge","x":420,"y":180,"wires":[["machineGroupControl_edge_dbg"]]}, + {"id":"machineGroupControl_edge_inj","type":"inject","z":"machineGroupControl_edge_tab","name":"unknown topic","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"doesNotExist","payload":"x","payloadType":"str","x":170,"y":180,"wires":[["machineGroupControl_edge_node"]]}, + {"id":"machineGroupControl_edge_dbg","type":"debug","z":"machineGroupControl_edge_tab","name":"machineGroupControl edge debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":660,"y":180,"wires":[]} +] diff --git a/examples/integration.flow.json b/examples/integration.flow.json new file mode 100644 index 0000000..58da112 --- /dev/null +++ b/examples/integration.flow.json @@ -0,0 +1,6 @@ +[ + {"id":"machineGroupControl_int_tab","type":"tab","label":"machineGroupControl integration","disabled":false,"info":"machineGroupControl integration example"}, + {"id":"machineGroupControl_int_node","type":"machineGroupControl","z":"machineGroupControl_int_tab","name":"machineGroupControl integration","x":420,"y":180,"wires":[["machineGroupControl_int_dbg"]]}, + {"id":"machineGroupControl_int_inj","type":"inject","z":"machineGroupControl_int_tab","name":"registerChild","props":[{"p":"topic","vt":"str"},{"p":"payload","vt":"str"}],"topic":"registerChild","payload":"example-child-id","payloadType":"str","x":170,"y":180,"wires":[["machineGroupControl_int_node"]]}, + {"id":"machineGroupControl_int_dbg","type":"debug","z":"machineGroupControl_int_tab","name":"machineGroupControl integration debug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":180,"wires":[]} +] diff --git a/package.json b/package.json index c42540c..f044e2b 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "description": "Control module machineGroupControl", "main": "mgc.js", "scripts": { - "test": "node mgc.js" + "test": "node --test test/basic/*.test.js test/integration/*.test.js test/edge/*.test.js" }, "repository": { "type": "git", @@ -24,4 +24,4 @@ "machineGroupControl": "mgc.js" } } -} \ No newline at end of file +} diff --git a/test/README.md b/test/README.md new file mode 100644 index 0000000..2015985 --- /dev/null +++ b/test/README.md @@ -0,0 +1,12 @@ +# machineGroupControl Test Suite Layout + +Required EVOLV layout: +- basic/ +- integration/ +- edge/ +- helpers/ + +Baseline structure tests: +- basic/structure-module-load.basic.test.js +- integration/structure-examples.integration.test.js +- edge/structure-examples-node-type.edge.test.js diff --git a/test/basic/.gitkeep b/test/basic/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/basic/structure-module-load.basic.test.js b/test/basic/structure-module-load.basic.test.js new file mode 100644 index 0000000..b8fc1f1 --- /dev/null +++ b/test/basic/structure-module-load.basic.test.js @@ -0,0 +1,8 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); + +test('machineGroupControl module load smoke', () => { + assert.doesNotThrow(() => { + require('../../mgc.js'); + }); +}); diff --git a/test/edge/.gitkeep b/test/edge/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/edge/structure-examples-node-type.edge.test.js b/test/edge/structure-examples-node-type.edge.test.js new file mode 100644 index 0000000..d6a629c --- /dev/null +++ b/test/edge/structure-examples-node-type.edge.test.js @@ -0,0 +1,11 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +const flow = JSON.parse(fs.readFileSync(path.resolve(__dirname, '../../examples/basic.flow.json'), 'utf8')); + +test('basic example includes node type machineGroupControl', () => { + const count = flow.filter((n) => n && n.type === 'machineGroupControl').length; + assert.equal(count >= 1, true); +}); diff --git a/test/helpers/.gitkeep b/test/helpers/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/.gitkeep b/test/integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/test/integration/structure-examples.integration.test.js b/test/integration/structure-examples.integration.test.js new file mode 100644 index 0000000..293eeac --- /dev/null +++ b/test/integration/structure-examples.integration.test.js @@ -0,0 +1,23 @@ +const test = require('node:test'); +const assert = require('node:assert/strict'); +const fs = require('node:fs'); +const path = require('node:path'); + +const dir = path.resolve(__dirname, '../../examples'); + +function loadJson(file) { + return JSON.parse(fs.readFileSync(path.join(dir, file), 'utf8')); +} + +test('examples package exists for machineGroupControl', () => { + for (const file of ['README.md', 'basic.flow.json', 'integration.flow.json', 'edge.flow.json']) { + assert.equal(fs.existsSync(path.join(dir, file)), true, file + ' missing'); + } +}); + +test('example flows are parseable arrays for machineGroupControl', () => { + for (const file of ['basic.flow.json', 'integration.flow.json', 'edge.flow.json']) { + const parsed = loadJson(file); + assert.equal(Array.isArray(parsed), true); + } +});