openvibers/openvibe.codes Commits

The conductor's tab draws its icon; every navbar icon is one Shared has (#190)

OP OpenVibers committed 14 days ago · 7daeb42240 · 2 files, +23 −1

fa-chart-simple is not in Shared's navbar icon set, so the conductor's tab showed an empty active pill on phones. It is
fa-diagram-project now. test/nav-icons.test.js checks every icon the layout names against the set, and fails on the
old name.

Changes

ddiff --git a/server/render/layout.js b/server/render/layout.js
iindex 7920ac0..f6b4f4d 100644
---- a/server/render/layout.js
++++ b/server/render/layout.js
@@@ -38,7 +38,7 @@ const NAV = [
const WORKSPACE_NAV = [
{ label: 'Home', href: '/', icon: 'fa-house' },
{ label: 'Tasks', href: '/tasks', icon: 'fa-list' },
-- { label: 'Conductor', href: '/conductor', icon: 'fa-chart-simple' },
++ { label: 'Conductor', href: '/conductor', icon: 'fa-diagram-project' },
{ label: 'Agents', href: '/agents', icon: 'fa-robot' },
{ label: 'Machines', href: '/machines', icon: 'fa-display' },
{ label: 'Usage', href: '/usage', icon: 'fa-chart-line' },
ddiff --git a/test/nav-icons.test.js b/test/nav-icons.test.js
nnew file mode 100644
iindex 0000000..933c6c9
---- /dev/null
++++ b/test/nav-icons.test.js
@@@ -0,0 +1,22 @@
++'use strict';
++// Every icon Codes names in its navbar and app bar exists in Shared's navbar icon set. A name the set does not have
++// draws nothing: the conductor's tab showed an empty active pill on phones (10-30, `fa-chart-simple`).
++const assert = require('assert');
++const fs = require('fs');
++const path = require('path');
++const { check, done } = require('./helpers/boot');
++
++const SHARED = path.join(__dirname, '..', 'node_modules', 'openvibe-shared', 'nav-icons.js');
++const LAYOUT = path.join(__dirname, '..', 'server', 'render', 'layout.js');
++
++(async () => {
++ await check('every navbar and app bar icon is one Shared can draw', () => {
++ const have = new Set(fs.readFileSync(SHARED, 'utf8').match(/fa-[a-z0-9-]+/g) || []);
++ assert.ok(have.size > 20, 'the shared icon set was read');
++ const used = [...new Set((fs.readFileSync(LAYOUT, 'utf8').match(/icon: '(fa-[a-z0-9-]+)'/g) || []).map((s) => s.slice(7, -1)))];
++ assert.ok(used.length > 5, 'the layout names its icons');
++ const missing = used.filter((name) => !have.has(name));
++ assert.deepStrictEqual(missing, [], `icons Shared does not have: ${missing.join(', ')}`);
++ });
++ done();
++})();