From 79d3be64f0a3e4552b08c80f1678649ccbff2a7c Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 11 Nov 2026 10:01:11 +0100 Subject: feat(windows): a new window brings the Windows tab forward When a window id appears that the last poll did not list, the tablet shows the Windows tab for [windows] peek seconds (default 8, 0 off) and then goes back to the tab it was on. A touch on the page or a tab change meanwhile keeps it there; another new window restarts the timer. The hook is generic: a panel's peek(state) returns seconds, app.js does the switching. The first poll only learns what is open, and an error state keeps what it knew, so neither triggers it. Co-Authored-By: Claude Opus 5.5 --- tests/test_windows.mjs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 tests/test_windows.mjs (limited to 'tests') diff --git a/tests/test_windows.mjs b/tests/test_windows.mjs new file mode 100644 index 0000000..534fd45 --- /dev/null +++ b/tests/test_windows.mjs @@ -0,0 +1,27 @@ +// deck-it - check for static/modules/windows.js: `node tests/test_windows.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"; +globalThis.document = { addEventListener() {} }; // the module wires a listener on load +const { default: windows } = await import("../static/modules/windows.js"); + +const st = (...ids) => ({ windows: ids.map((id) => ({ id })), peek: 5 }); +assert.equal(windows.peek(st("a", "b")), 0); // first poll only learns +assert.equal(windows.peek(st("a", "b")), 0); +assert.equal(windows.peek(st("a")), 0); // a close is not news +assert.equal(windows.peek(st("a", "c")), 5); // a new window is, for [windows] peek seconds +assert.equal(windows.peek({ error: "x" }), false); // an error keeps what it knew +assert.equal(windows.peek(st("a", "c")), 0); -- cgit v1.2.3