From c75b6f1ff69d944bb07b9395880a63620a0a8a00 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Tue, 10 Nov 2026 19:53:32 +0100 Subject: 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 --- tests/test_dashboard.mjs | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/test_dashboard.mjs (limited to 'tests/test_dashboard.mjs') 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. +// +// 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); -- cgit v1.2.3