fix live leaderbord details

This commit is contained in:
larssand
2026-08-28 21:12:43 +02:00
parent 3cf68cf34a
commit c6262aceab
15 changed files with 293 additions and 34 deletions

View File

@@ -5,6 +5,7 @@ import {
applyPersistedStateHelper,
hydrateFromBackendHelper,
syncStateToBackendHelper,
tickClockHelper,
} from "../src/runtime_services.js";
function withMockFetch(mock, callback) {
@@ -284,3 +285,29 @@ test("failed state sync leaves version and dirty state unchanged", async () => {
assert.equal(backend.available, false);
assert.equal(backend.lastError, "error.sync_failed:connection refused");
});
test("running timing clock updates without rebuilding the leaderboard details modal", () => {
let renders = 0;
let dynamicRefreshes = 0;
let headerRefreshes = 0;
const base = {
dom: { clock: { textContent: "" } },
currentLanguage: () => "sv",
getActiveSession: () => ({ status: "running" }),
getCurrentView: () => "timing",
getOverlayMode: () => false,
renderView: () => { renders += 1; },
refreshTimingDynamics: () => { dynamicRefreshes += 1; },
updateHeaderState: () => { headerRefreshes += 1; },
};
tickClockHelper({ ...base, handleSessionTimerTick: () => ({ changed: false }) });
assert.equal(dynamicRefreshes, 1);
assert.equal(renders, 0);
assert.equal(headerRefreshes, 0);
tickClockHelper({ ...base, handleSessionTimerTick: () => ({ changed: true }) });
assert.equal(dynamicRefreshes, 1);
assert.equal(renders, 1);
assert.equal(headerRefreshes, 1);
});