aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_dashboard.mjs
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-10 19:53:32 +0100
committerDanilo M. <danix@danix.xyz>2026-11-10 19:53:32 +0100
commitc75b6f1ff69d944bb07b9395880a63620a0a8a00 (patch)
tree85275188ebfbaf7863f0089b4644e089cd977604 /tests/test_dashboard.mjs
parentd0c5ae2bf4a8a0ab1ddec409e007e7aef0dfc3e3 (diff)
downloaddeck-it-c75b6f1ff69d944bb07b9395880a63620a0a8a00.tar.gz
deck-it-c75b6f1ff69d944bb07b9395880a63620a0a8a00.zip
feat(dashboard): one fixed screen for the tablet
The Dashboard tab drops the draggable card grid for a fixed layout: a top band of system, Claude and tablet chips with trend and fill backgrounds, music and spending always on, a row of one to three busy modules (printer, build VM, OBS) that scroll long lines, and the action icons in Hyprland's rotating border. The stats, tablet and llm panels and the vendored Gridstack go. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/test_dashboard.mjs')
-rw-r--r--tests/test_dashboard.mjs55
1 files changed, 55 insertions, 0 deletions
diff --git a/tests/test_dashboard.mjs b/tests/test_dashboard.mjs
new file mode 100644
index 0000000..2fc19eb
--- /dev/null
+++ b/tests/test_dashboard.mjs
@@ -0,0 +1,55 @@
+// deck-it - check for static/dashboard.js: `node tests/test_dashboard.mjs`
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program; if not, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+import assert from "node:assert/strict";
+import { area, push, spendParts, batteryGlyph, HISTORY } from "../static/dashboard.js";
+import { busy as printing } from "../static/modules/k1c.js";
+import { busy as building } from "../static/modules/sbbuilder.js";
+import { busy as live } from "../static/modules/obs.js";
+
+// push keeps the last HISTORY samples
+const h = [];
+for (let i = 0; i < HISTORY + 5; i++) push(h, i);
+assert.equal(h.length, HISTORY);
+assert.equal(h[0], 5);
+
+// area: empty without samples; closed path from the bottom edge to the right edge
+assert.equal(area([], 10), "");
+const d = area([0, 10], 10);
+assert.match(d, /^M[\d.]+,100 /);
+assert.match(d, / L120,100 Z$/);
+assert.ok(d.includes(",12"), "the max sample sits at 12% from the top");
+
+// spendParts: top 3 paid models, then "other" with the rest
+const models = [5, 4, 3, 2, 1, 0].map((c, i) => ({ model: `m${i}`, cost: c }));
+assert.deepEqual(spendParts(models).map((m) => [m.model, m.cost]),
+ [["m0", 5], ["m1", 4], ["m2", 3], ["other", 3]]);
+assert.deepEqual(spendParts([{ model: "free", cost: 0 }]), []);
+
+// batteryGlyph: level steps, bolt while charging or full
+assert.equal(batteryGlyph({ level: 3, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 50, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 100, status: "discharging" }), "");
+assert.equal(batteryGlyph({ level: 40, status: "charging" }), "\u{f0084}");
+
+// busy checks
+assert.equal(printing({ state: "printing" }), true);
+assert.equal(printing({ state: "standby" }), false);
+assert.equal(printing({ offline: true }), false);
+assert.equal(building({ jobs: [{ status: "running" }] }), true);
+assert.equal(building({ jobs: [{ status: "done" }] }), false);
+assert.equal(live({ connected: true, recording: true }), true);
+assert.equal(live({ connected: true, recording: false, streaming: false }), false);