v0.31.3
This commit is contained in:
1 parent
0facfe6f5c
commit
95c55da2ee
39 files changed
+715
-151
No files matched your search
@@ -14,7 +14,7 @@ assert.match(bridge, /function startLive\(/);
|
||||
|
||||
function fixture({ withoutSse = false } = {}) {
|
||||
let time = 0, nextId = 1, renderCount = 0, logCount = 0, diagCount = 0;
|
||||
const timers = new Map(), listeners = new Map(), streams = [], requests = [], rendered = [], failures = [];
|
||||
const timers = new Map(), listeners = new Map(), windowListeners = new Map(), streams = [], requests = [], rendered = [], failures = [];
|
||||
let response = async () => ({});
|
||||
class FakeEventSource {
|
||||
constructor(url) { this.url = url; this.closed = false; this.handlers = new Map(); streams.push(this); }
|
||||
@@ -37,7 +37,11 @@ function fixture({ withoutSse = false } = {}) {
|
||||
console: { warn(...args) { failures.push(args); } },
|
||||
authenticated: true, authEpoch: 1, currentPanel: "overview", liveConnected: false, liveFallback: false,
|
||||
liveEvents: null, liveInterval: null, latestStatus: null,
|
||||
window: { rustProxySettings: { current: () => "listeners", render: () => undefined } },
|
||||
window: {
|
||||
rustProxySettings: { current: () => "listeners", render: () => undefined },
|
||||
addEventListener(type, callback) { assert(!windowListeners.has(type)); windowListeners.set(type, callback); },
|
||||
removeEventListener(type, callback) { assert.equal(windowListeners.get(type), callback); windowListeners.delete(type); },
|
||||
},
|
||||
$: name => nodes[name] || null,
|
||||
t: name => name,
|
||||
api: (url, args = {}) => { requests.push({ url, args, time }); return response(url, args); },
|
||||
@@ -45,7 +49,11 @@ function fixture({ withoutSse = false } = {}) {
|
||||
renderLogs() { logCount++; },
|
||||
renderDiagnostics() { diagCount++; },
|
||||
renderLiveStatus() { throw new Error("bridge not loaded"); },
|
||||
revalidateSession: async () => undefined,
|
||||
revalidateSession: async () => {
|
||||
ctx.window.rustProxyRefresh.suspendForSessionValidation();
|
||||
await Promise.resolve();
|
||||
ctx.window.rustProxyRefresh.completeSessionValidation(true);
|
||||
},
|
||||
loadTunnels: async () => undefined
|
||||
};
|
||||
runInNewContext(bridge + "\n" + scheduler, ctx, { filename: "coordinator-browser-bundle.js" });
|
||||
@@ -76,7 +84,7 @@ function fixture({ withoutSse = false } = {}) {
|
||||
}
|
||||
}
|
||||
return {
|
||||
ctx, refresh, requests, rendered, streams, listeners, timers, failures, advance, switchPanel, count,
|
||||
ctx, refresh, requests, rendered, streams, listeners, windowListeners, timers, failures, advance, switchPanel, count,
|
||||
registerViews, changeVisibility,
|
||||
setResponse(fn) { response = fn; },
|
||||
get renderCount() { return renderCount; },
|
||||
@@ -152,7 +160,7 @@ assert(h.streams.at(-1).closed, "SSE closes when hidden");
|
||||
assert.equal(h.refresh.diagnostics().filter(row => row.scheduled).length, 0);
|
||||
await h.advance(120_000);
|
||||
assert.equal(h.count("/api/traffic"), beforeHidden);
|
||||
h.changeVisibility(false); await h.advance();
|
||||
h.changeVisibility(false); await h.advance(); await h.advance();
|
||||
assert.equal(h.count("/api/traffic"), beforeHidden + 1);
|
||||
assert.equal(h.streams.filter(stream => !stream.closed).length, 1);
|
||||
|
||||
@@ -206,6 +214,7 @@ assert.throws(() => h.refresh.register("traffic", { interval: () => 5, run: asyn
|
||||
// Logout clears timers, active SSE streams, observer and pending fetches.
|
||||
h.refresh.stop();
|
||||
assert.equal(h.listeners.has("visibilitychange"), false);
|
||||
assert.equal(h.windowListeners.size, 0, "pagehide/pageshow listeners are removed on logout");
|
||||
assert.equal(h.streams.filter(stream => !stream.closed).length, 0);
|
||||
assert.equal(h.refresh.diagnostics().filter(row => row.scheduled).length, 0);
|
||||
const afterLogout = h.requests.length;
|
||||
|
||||
Reference in new issue
Block a user