// test/skland/panel.test.js — public/skland.html, the standalone Skland binding panel (scan / SMS / password).
//
// The panel is one self-contained HTML file with an inline module script (no build step, no browser test), so this
// test reads it as TEXT and pins only the contract facts that would silently rot: the endpoints it calls, that the QR
// encodes the scanUrl deep link (NOT the scan session id), that captcha challenges are handled, that a 404 reads as
// "the module is off", and that the 2 s polling loop always gets cleared.
// String checks like these are deliberately few and each one names the failure it prevents.
import { test, describe } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync, existsSync } from 'node:fs';
import path from 'node:path';
import { fileURLToPath } from 'node:url';
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../..');
const HTML_PATH = path.join(ROOT, 'public', 'skland.html');
describe('the Skland binding panel (public/skland.html)', () => {
assert.ok(existsSync(HTML_PATH), 'the panel is a real file the static server can serve');
const html = readFileSync(HTML_PATH, 'utf8');
test('is one whole document: a doctype, an inline module script and a closed html tag', () => {
// A stray `` or an unclosed tag is exactly the kind of damage a text-only test can catch.
assert.match(html, /^/i);
assert.equal((html.match(/