aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-11-11 10:01:11 +0100
committerDanilo M. <danix@danix.xyz>2026-11-11 10:01:11 +0100
commit79d3be64f0a3e4552b08c80f1678649ccbff2a7c (patch)
tree9f6532b6119a6a71dd08d108bd1527cec6b8ce41 /tests
parent978ec811803cdbeb10dc2e6924ab33aa2b84bec6 (diff)
downloaddeck-it-79d3be64f0a3e4552b08c80f1678649ccbff2a7c.tar.gz
deck-it-79d3be64f0a3e4552b08c80f1678649ccbff2a7c.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/test_windows.mjs27
1 files changed, 27 insertions, 0 deletions
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. <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";
+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);