fix(control): followers update live, phones use the page address, master is visible (1.77.2)

This commit is contained in:
larssand committed 2026-11-07 18:09:34 +01:00
1 parent 0589fe5f65
commit a4e734dd74
13 files changed
+119 -22

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
import test from "node:test";
import assert from "node:assert/strict";
import { resolveBackendUrl } from "../src/backend_url.js";
const phone = { protocol: "http:", hostname: "192.168.1.46", origin: "http://192.168.1.46:8081" };
const laptop = { protocol: "http:", hostname: "localhost", origin: "http://localhost:8081" };
test("a phone on the laptop's IP ignores the laptop's saved localhost address", () => {
assert.equal(resolveBackendUrl("http://localhost:8081", phone), "http://192.168.1.46:8081");
assert.equal(resolveBackendUrl("http://127.0.0.1:8081/", phone), "http://192.168.1.46:8081");
assert.equal(resolveBackendUrl("http://localhost:8081", laptop), "http://localhost:8081", "the laptop keeps it");
assert.equal(resolveBackendUrl("http://10.0.0.5:8081", phone), "http://10.0.0.5:8081", "a real address set on purpose is kept");
assert.equal(resolveBackendUrl("", phone), "http://192.168.1.46:8081");
assert.equal(resolveBackendUrl("", { protocol: "file:" }), "http://127.0.0.1:8081");
});
+10 -5
View File
@@ -21,12 +21,13 @@ export async function runRaceControllerSmoke({ evaluate, navigate, savedState, w
const firstId = await evaluate('sessionStorage.getItem("rc_controller_client_id")');
await waitFor(async () => (await controller())?.clientId === firstId, "the first admin browser is the master");
await waitFor(async () => await evaluate('document.getElementById("connectionBadge")?.classList.contains("badge-online")'), "master connects to the decoder");
assert.equal(await evaluate('document.getElementById("controllerBanner").hidden'), true, "no banner on the master");
await waitFor(async () => await evaluate('!document.getElementById("controllerBanner").hidden && document.getElementById("controllerBanner").classList.contains("is-master")'), "the master sees that it is the master");
assert.ok(await evaluate('Boolean(document.getElementById("controllerRelease"))'), "with a Release button");
const connectsBefore = decoder.totalConnections();
target = await (await fetch(`http://127.0.0.1:${debugPort}/json/new?${encodeURIComponent(base + "/?view=settings")}`, { method: "PUT" })).json();
second = await attach(target);
await second.waitFor(async () => (await second.evaluate('document.getElementById("controllerBanner")?.hidden')) === false, "second browser shows the follow banner");
await second.waitFor(async () => Boolean(await second.evaluate('document.getElementById("controllerTakeOver")')), "second browser shows the follow banner");
await pause(1500);
assert.equal(decoder.totalConnections(), connectsBefore, "the second browser does not connect to the decoder");
assert.match(await second.evaluate('document.getElementById("controllerBanner").textContent'), /Race Controller Master/);
@@ -36,11 +37,15 @@ export async function runRaceControllerSmoke({ evaluate, navigate, savedState, w
const heat = { id: "rc_ctrl_heat", eventId: before.events[0]?.id || "", name: "RC Ctrl Heat", type: "final", mode: "race", status: "paused", startMode: "position", durationMin: 5, startedAt: Date.now() - 60000, pausedAt: Date.now() - 30000, totalPausedMs: 0, driverIds: [] };
await patchState({ sessions: [...before.sessions, heat], activeSessionId: heat.id });
await second.evaluate(`location.href = ${JSON.stringify(base + "/?view=race_day")}; true`);
await second.waitFor(async () => Boolean(await second.evaluate('document.querySelector(\'#speakerPanel [data-race-audio-cue="race_resumed"]\')')) && (await second.evaluate('document.getElementById("controllerBanner").hidden')) === false, "follower on Race Day");
await second.waitFor(async () => Boolean(await second.evaluate('document.querySelector(\'#speakerPanel [data-race-audio-cue="race_resumed"]\')')) && Boolean(await second.evaluate('document.getElementById("controllerTakeOver")')), "follower on Race Day");
await second.evaluate('document.querySelector(\'#speakerPanel [data-race-audio-cue="race_resumed"]\').click(); true');
await pause(1500);
assert.equal((await savedState()).sessions.find((session) => session.id === heat.id).status, "paused", "the follower's Resume does nothing");
assert.equal(await second.evaluate('document.getElementById("controllerBanner").classList.contains("is-flash")'), true, "the banner points at Take over");
// The follower is updated live from the server, without a reload.
const renamed = await savedState();
await patchState({ sessions: renamed.sessions.map((session) => (session.id === heat.id ? { ...session, name: "RC Ctrl Heat Live" } : session)) });
await second.waitFor(async () => (await second.evaluate("document.querySelector('.content').innerText")).includes("RC Ctrl Heat Live"), "the follower shows the change within seconds", 5000);
const cleaned = await savedState();
await patchState({ sessions: cleaned.sessions.filter((session) => session.id !== heat.id), activeSessionId: before.activeSessionId || null });
@@ -48,9 +53,9 @@ export async function runRaceControllerSmoke({ evaluate, navigate, savedState, w
const secondId = await second.evaluate('sessionStorage.getItem("rc_controller_client_id")');
await waitFor(async () => (await controller())?.clientId === secondId, "take over moves the master");
await waitFor(async () => decoder.totalConnections() > connectsBefore, "the new master connects to the decoder");
await waitFor(async () => (await evaluate('document.getElementById("controllerBanner").hidden')) === false, "the old master sees the banner", 12000);
await waitFor(async () => Boolean(await evaluate('document.getElementById("controllerTakeOver")')), "the old master sees the follow banner", 12000);
assert.equal(await evaluate("document.getElementById('connectionBadge').classList.contains('badge-online')"), false, "the old master lets go of the decoder");
console.log("PASS Race Controller Master: a second browser follows without the decoder or pause/resume, takes over, and the first one lets go");
console.log("PASS Race Controller Master: a second browser follows live without the decoder or pause/resume, takes over, and the first one lets go");
// Back to the first browser for the rest of the suite.
await evaluate('window.confirm = () => true; document.getElementById("controllerTakeOver").click(); true');
+1
View File
@@ -1,4 +1,5 @@
import "./auth.test.js";
import "./backend_url.test.js";
import "./judging_penalties.test.js";
import "./practice_rank.test.js";
import "./team_race_logic.test.js";