This commit is contained in:
Mateusz Gruszczyński
2026-09-17 12:55:29 +02:00
parent 4bdcf1b8dd
commit cd8d3fab95
42 changed files with 286 additions and 842 deletions
+16 -2
View File
@@ -31,7 +31,7 @@ const app = {
settings: { house_mode: 'cool', debug: { overlay_enabled: false }, home_assistant: {} },
system: {}, outdoorTemperature: null, controlPlan: null, controlPlanRevision: null,
controlPlanPushReady: false, controlPlanTimer: null, currentView: 'dashboard',
sensorAliases: {}, flowSharedInputs: [], flowDraft: null, ws: null, wsTimer: null,
sensorAliases: {}, flowSharedInputs: [], flowDraft: null, ws: null, wsTimer: null, wsErrorTimer: null, wsOutageStartedAt: 0,
token: '', debugBacklogLoaded: false,
};
@@ -278,7 +278,21 @@ async function main() {
socket.readyState = FakeWebSocket.CLOSED;
socket.onclose();
assert.equal(app.controlPlanPushReady, false);
assert(timers.length >= beforeCloseTimers + 2, 'close must schedule fallback and reconnect');
assert.equal(calls['connection:reconnecting'], 1, 'short WS outage must show reconnecting state');
assert(timers.length >= beforeCloseTimers + 3, 'close must schedule fallback, reconnect and delayed error state');
const errorTimer = timers.find(item => !item.cleared && item.delay === 15000);
assert(errorTimer, 'persistent WS outage must schedule a delayed connection-error state');
errorTimer.fn();
assert.equal(calls['connection:connectionError'], 1, 'persistent WS outage must become a connection error');
const reconnectTimer = timers.find(item => !item.cleared && item.delay === 3000);
assert(reconnectTimer, 'WS close must schedule reconnect');
reconnectTimer.fn();
const reconnectedSocket = FakeWebSocket.instances[FakeWebSocket.instances.length - 1];
reconnectedSocket.readyState = FakeWebSocket.OPEN;
reconnectedSocket.onopen();
assert.equal(calls['connection:connected'], 2, 'successful reconnect must restore connected state');
assert.equal(app.wsOutageStartedAt, 0, 'successful reconnect must clear outage tracking');
console.log(`Live realtime test OK (${apiCalls.length} API fallback/resync calls observed)`);
}