Files
trx-rs/src/trx-client/trx-frontend/trx-frontend-http/frontend/tests/host-fixture.mjs
T
sjg e70e82c8c0
CI / lint (push) Successful in 2m17s
CI / test (push) Successful in 8m8s
CI / frontend (push) Failing after 36s
CI / reuse (push) Successful in 4s
[feat](trx-frontend-http): rebuild the general radio controls row
Mode was a full-width select: 483px of the row to display "FM".  The
modes are three or four characters and there are at most twelve, so they
become a segmented group like the Unit and Step Scale pickers beside
them — a third of the width, and one click instead of two.

The <select> stays as the mode's value.  A dozen call sites and several
plugins read #mode.value, so replacing it outright would have reached
much further than a layout change should; it is hidden from sight and
from assistive tech, the buttons write to it, and everything downstream
runs unchanged.  Every writer re-syncs the buttons, the plugins through
a new trxCore.syncModePicker.

The row itself was a grid with a track per column, but the WFM, SAM and
transmit columns are hidden on most rigs, so it ended in some 500px of
hole.  It packs left now.  Same fault one level down: the power buttons
sat in three fixed tracks, so a rig with neither transmit nor lock kept
two empty ones and left its label chip stranded at the far edge.

Unit and Step Scale move out of the frequency row and in beside the
wheel and the +/- they modify, which were some 600px away.

Signed-off-by: Stan Grams <sjg@haxx.space>
2026-08-03 22:09:08 +02:00

68 lines
2.5 KiB
JavaScript

// SPDX-FileCopyrightText: 2026 Stan Grams <sjg@haxx.space>
//
// SPDX-License-Identifier: GPL-2.0-or-later
// Mirrors the `window.trx` host contract that app.ts publishes and that
// src/plugins/host.ts consumes. Feature bundles read all application state
// and services through it, so every plugin test needs it on its stub window.
export function createHost({ state = {}, core = {}, modules = {} } = {}) {
const calls = [];
const record = (name, result) => (...args) => {
calls.push({ name, args });
return typeof result === "function" ? result(...args) : result;
};
return {
calls,
trx: {
state: {
serverLat: null,
serverLon: null,
authEnabled: false,
authRole: "control",
lastActiveRigId: null,
lastRigIds: [],
lastRigDisplayNames: {},
lastFreqHz: null,
lastSpectrumData: null,
jogUnit: 1000,
rxActive: false,
decoderRegistry: [],
lastModeName: "",
currentBandwidthHz: 2400,
audioChannelOverride: null,
...state,
},
core: {
postPath: record("postPath", async () => undefined),
applyLocalTunedFrequency: record("applyLocalTunedFrequency"),
armOptimisticFrequency: record("armOptimisticFrequency"),
escapeMapHtml: (value) => String(value)
.replaceAll("&", "&amp;").replaceAll("<", "&lt;")
.replaceAll(">", "&gt;").replaceAll('"', "&quot;"),
haversineKm: record("haversineKm", () => 0),
showHint: record("showHint"),
formatFreqForStep: (hz) => String(hz),
refreshFreqDisplay: record("refreshFreqDisplay"),
setJogDivisor: record("setJogDivisor"),
mwDefaultsForMode: record("mwDefaultsForMode", () => [0, 0, 0, 0]),
resetRdsDisplay: record("resetRdsDisplay"),
positionRdsPsOverlay: record("positionRdsPsOverlay"),
updateWfmControls: record("updateWfmControls"),
updateSdrSquelchControlVisibility: record("updateSdrSquelchControlVisibility"),
updateDocumentTitle: record("updateDocumentTitle"),
activeChannelRds: record("activeChannelRds", () => null),
startRxAudio: record("startRxAudio"),
stopRxAudio: record("stopRxAudio"),
setRigFrequency: record("setRigFrequency"),
syncBandwidthInput: record("syncBandwidthInput"),
scheduleSpectrumDraw: record("scheduleSpectrumDraw"),
syncModePicker: record("syncModePicker"),
onDecoderRegistryReady: record("onDecoderRegistryReady"),
...core,
},
modules,
},
};
}