mirror of
https://github.com/Youzini-afk/ST-Bionic-Memory-Ecology.git
synced 2026-05-15 22:30:38 +08:00
perf: reduce graph panel refresh churn during streaming
This commit is contained in:
186
tests/panel-graph-refresh.mjs
Normal file
186
tests/panel-graph-refresh.mjs
Normal file
@@ -0,0 +1,186 @@
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import {
|
||||
buildVisibleGraphRefreshToken,
|
||||
resolveVisibleGraphWorkspaceMode,
|
||||
} from "../ui/panel-graph-refresh-utils.js";
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: false,
|
||||
isMobile: false,
|
||||
currentTabId: "dashboard",
|
||||
currentGraphView: "graph",
|
||||
}),
|
||||
"hidden",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: false,
|
||||
currentTabId: "config",
|
||||
currentGraphView: "graph",
|
||||
}),
|
||||
"hidden",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: false,
|
||||
currentTabId: "dashboard",
|
||||
currentGraphView: "graph",
|
||||
}),
|
||||
"desktop:graph",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: false,
|
||||
currentTabId: "memory",
|
||||
currentGraphView: "cognition",
|
||||
}),
|
||||
"desktop:cognition",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: false,
|
||||
currentTabId: "actions",
|
||||
currentGraphView: "summary",
|
||||
}),
|
||||
"desktop:summary",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: true,
|
||||
currentTabId: "dashboard",
|
||||
currentMobileGraphView: "graph",
|
||||
}),
|
||||
"hidden",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: true,
|
||||
currentTabId: "graph",
|
||||
currentMobileGraphView: "graph",
|
||||
}),
|
||||
"mobile:graph",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: true,
|
||||
currentTabId: "graph",
|
||||
currentMobileGraphView: "cognition",
|
||||
}),
|
||||
"mobile:cognition",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
resolveVisibleGraphWorkspaceMode({
|
||||
overlayActive: true,
|
||||
isMobile: true,
|
||||
currentTabId: "graph",
|
||||
currentMobileGraphView: "summary",
|
||||
}),
|
||||
"mobile:summary",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "hidden",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
"hidden",
|
||||
);
|
||||
|
||||
const baseToken = buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:graph",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
baseToken,
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:graph",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.notEqual(
|
||||
baseToken,
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:graph",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 13,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.notEqual(
|
||||
baseToken,
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:cognition",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.notEqual(
|
||||
baseToken,
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:graph",
|
||||
chatId: "chat-side",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 40,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
);
|
||||
|
||||
assert.notEqual(
|
||||
baseToken,
|
||||
buildVisibleGraphRefreshToken({
|
||||
visibleMode: "desktop:graph",
|
||||
chatId: "chat-main",
|
||||
loadState: "loaded",
|
||||
revision: 12,
|
||||
nodeCount: 41,
|
||||
edgeCount: 55,
|
||||
lastProcessedSeq: 9,
|
||||
}),
|
||||
);
|
||||
|
||||
console.log("panel-graph-refresh tests passed");
|
||||
Reference in New Issue
Block a user