CI / lint (pull_request) Failing after 2s
CI / test (pull_request) Failing after 1s
CI / frontend (pull_request) Failing after 41s
CI / reuse (pull_request) Failing after 2s
CI / lint (push) Failing after 2s
CI / test (push) Failing after 2s
CI / frontend (push) Failing after 36s
CI / reuse (push) Failing after 1s
The bookmark fix addressed one instance of a defect the TypeScript migration left across the feature entries. app.js stopped being a classic script, so its top-level declarations are no longer shared globals, but the converted entries kept reading them as window properties that nothing publishes. Restore the broken behavior: - ais, aprs, hf-aprs read serverLat, serverLon and haversineKm as undefined, so every positioned packet rendered an empty distance. - ais, aprs, hf-aprs, cw, sat, vdes, wefax, wspr called an undefined postPath, so clear-history and decoder toggles threw. - scheduler read authRole as undefined, so the lazy-load path never self-initialized and the Settings tab opened an inert scheduler. - background-decode read authEnabled as undefined, so control gating fell back to role-only. - vchan read fifteen application values and services as undefined: mode and bandwidth sync, the out-of-band hint, RX audio restart, and the frequency field all silently no-opped on a virtual channel. - vchan wrapped window.refreshFreqDisplay, capturing an undefined original exactly as it did for setRigFrequency, so leaving a channel never restored the application's own frequency display. - _audioChannelOverride was a const that nothing could assign, so RX audio always subscribed to the primary channel. - ftx-family read fmtTime, a helper legacy ft8.js owned locally, so decode bar timestamps rendered empty. Declare the contract once in plugins/host.ts and import it from the feature entries, rather than restoring globals that docs/frontend-architecture.md excludes. trx.state gains jogUnit, rxActive and audioChannelOverride, and makes lastModeName writable; trx.core gains the tuning, RDS, WFM, jog and RX audio services the entries need. vchan interception moves to an interceptFreqDisplay service method that refreshFreqDisplay calls, matching the frequency, mode and bandwidth interception it already registers. Reading registry-built elements through a strict lookup is the same defect as in bookmarks: renderTimelineNeedle guards its result, but schedulerEl throws, so the now-initializing scheduler crashed on the timeline needle group that its own SVG creates. Feature tests move onto a shared host fixture, and entries that now import a common module are bundled through bundleEntry like the other shared-module entries. Covers scheduler self-initialization and the distance path that the bare window reads broke. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GdyUjuXejCEfiub675z6cz Signed-off-by: Stan Grams <sjg@haxx.space>
89 lines
3.3 KiB
JavaScript
89 lines
3.3 KiB
JavaScript
// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
|
|
//
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import vm from "node:vm";
|
|
import { bundleEntry } from "./bundle-entry.mjs";
|
|
import { createHost } from "./host-fixture.mjs";
|
|
|
|
test("APRS entry normalizes positioned packets without remote symbol assets", async () => {
|
|
const forwarded = [];
|
|
const window = {
|
|
...createHost(),
|
|
trxUi: { confirm: async () => true },
|
|
aprsMapAddStation: (...args) => { forwarded.push(args); },
|
|
};
|
|
const context = vm.createContext({
|
|
window,
|
|
document: { getElementById: () => null, querySelectorAll: () => [] },
|
|
navigator: {},
|
|
Date,
|
|
Number,
|
|
String,
|
|
Array,
|
|
Set,
|
|
Reflect,
|
|
console,
|
|
});
|
|
const runtime = await bundleEntry(new URL("../src/plugin-runtime.ts", import.meta.url));
|
|
const source = await bundleEntry(new URL("../src/plugins/aprs.ts", import.meta.url));
|
|
assert.equal(source.includes("raw.githubusercontent.com"), false);
|
|
new vm.Script(runtime).runInContext(context);
|
|
new vm.Script(source).runInContext(context);
|
|
|
|
window.trxPluginRuntime.dispatch("aprs", { src_call: "SP0ABC", dest_call: "APRS", crc_ok: true, lat: 54.5, lon: 18.5, symbol_table: "/", symbol_code: ">" });
|
|
assert.equal(window.onServerAprs, undefined);
|
|
assert.equal(forwarded.length, 1);
|
|
assert.equal(forwarded[0][0], "SP0ABC");
|
|
assert.equal(forwarded[0][1], 54.5);
|
|
assert.equal(forwarded[0][6].rig_id, null);
|
|
});
|
|
|
|
// Distance is computed from the receiver position and the great-circle helper,
|
|
// both of which the entry reads through the host contract. These used to be
|
|
// bare window properties that the module graph stopped publishing, so the
|
|
// distance column rendered empty for every positioned packet.
|
|
test("APRS distance text uses the receiver position from the host contract", async () => {
|
|
const distanceArgs = [];
|
|
const host = createHost({
|
|
state: { serverLat: 54.0, serverLon: 18.0 },
|
|
core: {
|
|
haversineKm: (lat1, lon1, lat2, lon2) => {
|
|
distanceArgs.push([lat1, lon1, lat2, lon2]);
|
|
return 61.7;
|
|
},
|
|
},
|
|
});
|
|
const window = { ...host, trxUi: { confirm: async () => true }, aprsMapAddStation: () => {} };
|
|
const node = () => ({
|
|
innerHTML: "", textContent: "", className: "", style: {}, dataset: {},
|
|
appendChild(child) { return child; }, addEventListener() {}, replaceChildren() {},
|
|
querySelector: () => null, querySelectorAll: () => [], setAttribute() {},
|
|
classList: { add() {}, toggle() {} },
|
|
});
|
|
const context = vm.createContext({
|
|
window,
|
|
document: {
|
|
getElementById: (id) => (id === "aprs-packets" ? node() : null),
|
|
querySelectorAll: () => [],
|
|
createElement: node,
|
|
createDocumentFragment: node,
|
|
},
|
|
navigator: {},
|
|
Date, Number, String, Array, Set, Reflect, console,
|
|
});
|
|
const runtime = await bundleEntry(new URL("../src/plugin-runtime.ts", import.meta.url));
|
|
const source = await bundleEntry(new URL("../src/plugins/aprs.ts", import.meta.url));
|
|
new vm.Script(runtime).runInContext(context);
|
|
new vm.Script(source).runInContext(context);
|
|
|
|
window.trxPluginRuntime.dispatch("aprs", {
|
|
src_call: "SP0ABC", dest_call: "APRS", crc_ok: true, lat: 54.5, lon: 18.5,
|
|
symbol_table: "/", symbol_code: ">",
|
|
});
|
|
|
|
assert.deepEqual(distanceArgs, [[54.0, 18.0, 54.5, 18.5]]);
|
|
});
|