openvibers/openvibe.bot Commits
Test: the embedded panel draws every control the whole panel does, for every built-in profile
Changes
nnew file mode 100644@@@ -0,0 +1,32 @@++'use strict';++// One panel, embedded or whole (plan §H.11; Maticus, 11-13: "headlights work but the controls don't show up anywhere but++// in the main .bot panel"): for every built-in robot profile, the panel embedded under a stream draws every control,++// widget and the headlights the owner's whole panel draws. A control may be hidden until Drive, never missing.++const assert = require('assert');++const fs = require('fs');++const path = require('path');++const render = require('../server/web/render');++++const dir = path.join(__dirname, '..', 'server', 'profiles');++// The owner's allowed kinds (server/domain/index.js DEFAULT_ALLOW.owner).++const owner = ['drive', 'actuator', 'ptz', 'say', 'display', 'button', 'point', 'headlight', 'setting', 'halt'];++const sets = (html) => ({++ parts: new Set([...html.matchAll(/data-ov-part="([^"]+)"/g)].map((m) => m[1])),++ widgets: new Set([...html.matchAll(/data-widget="([^"]+)"/g)].map((m) => m[1])),++ headlight: /data-headlight\b/.test(html),++});++const files = fs.readdirSync(dir).filter((f) => f.endsWith('.json'));++assert.ok(files.length >= 8, `the built-in profiles are here (${files.length})`);++let checked = 0;++for (const f of files) {++ const profile = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));++ const robot = { id: 'rob_x', name: 'X', profile_id: profile.id, access_policy: 'private' };++ const whole = sets(render.renderPanel({ robot, profile, role: 'owner', allowed_commands: owner, mode: 'page', view: 'panel' }));++ const embedded = sets(render.renderPanel({ robot, profile, role: 'owner', allowed_commands: owner, mode: 'embed', view: 'panel' }));++ for (const p of whole.parts) assert.ok(embedded.parts.has(p), `${f}: the embedded panel draws the ${p} the whole panel has`);++ for (const w of whole.widgets) assert.ok(embedded.widgets.has(w), `${f}: the embedded panel draws the ${w} widget`);++ if (whole.headlight) assert.ok(embedded.headlight, `${f}: the headlights are in the embedded panel too`);++ checked += 1;++}++assert.ok(/"headlight"/.test(fs.readFileSync(path.join(dir, 'looi.json'), 'utf8')), 'LOOI declares its headlights (the case Maticus found)');++console.log(`embed-parity: ${checked} profiles, the embedded panel draws every control the whole panel does`);
new file mode 100644
new file mode 100644
@@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
+'use strict';
+// One panel, embedded or whole (plan §H.11; Maticus, 11-13: "headlights work but the controls don't show up anywhere but
+// in the main .bot panel"): for every built-in robot profile, the panel embedded under a stream draws every control,
+// widget and the headlights the owner's whole panel draws. A control may be hidden until Drive, never missing.
+const assert = require('assert');
+const fs = require('fs');
+const path = require('path');
+const render = require('../server/web/render');
+
+const dir = path.join(__dirname, '..', 'server', 'profiles');
+// The owner's allowed kinds (server/domain/index.js DEFAULT_ALLOW.owner).
+const owner = ['drive', 'actuator', 'ptz', 'say', 'display', 'button', 'point', 'headlight', 'setting', 'halt'];
+const sets = (html) => ({
+ parts: new Set([...html.matchAll(/data-ov-part="([^"]+)"/g)].map((m) => m[1])),
+ widgets: new Set([...html.matchAll(/data-widget="([^"]+)"/g)].map((m) => m[1])),
+ headlight: /data-headlight\b/.test(html),
+});
+const files = fs.readdirSync(dir).filter((f) => f.endsWith('.json'));
+assert.ok(files.length >= 8, `the built-in profiles are here (${files.length})`);
+let checked = 0;
+for (const f of files) {
+ const profile = JSON.parse(fs.readFileSync(path.join(dir, f), 'utf8'));
+ const robot = { id: 'rob_x', name: 'X', profile_id: profile.id, access_policy: 'private' };
+ const whole = sets(render.renderPanel({ robot, profile, role: 'owner', allowed_commands: owner, mode: 'page', view: 'panel' }));
+ const embedded = sets(render.renderPanel({ robot, profile, role: 'owner', allowed_commands: owner, mode: 'embed', view: 'panel' }));
+ for (const p of whole.parts) assert.ok(embedded.parts.has(p), `${f}: the embedded panel draws the ${p} the whole panel has`);
+ for (const w of whole.widgets) assert.ok(embedded.widgets.has(w), `${f}: the embedded panel draws the ${w} widget`);
+ if (whole.headlight) assert.ok(embedded.headlight, `${f}: the headlights are in the embedded panel too`);
+ checked += 1;
+}
+assert.ok(/"headlight"/.test(fs.readFileSync(path.join(dir, 'looi.json'), 'utf8')), 'LOOI declares its headlights (the case Maticus found)');
+console.log(`embed-parity: ${checked} profiles, the embedded panel draws every control the whole panel does`);