feat: refactor DashCommand to use useMemo for shortcuts and server commands

feat: optimize GlobalMap component with useMemo for country data processing

feat: enhance ServerCard and ServerCardInline components with memoization

feat: improve ServiceTracker component by processing service data with useMemo

feat: add VirtualServerList component for efficient rendering of server lists

refactor: update Servers page to utilize VirtualServerList for better performance

test: add tests for DashCommand and GlobalMap components, including virtualization checks
This commit is contained in:
hamster1963
2026-07-05 04:09:22 +08:00
parent 8f3a2f3eb3
commit 6c7ba30cee
14 changed files with 998 additions and 338 deletions
+22 -1
View File
@@ -339,7 +339,28 @@ describe("Servers page", () => {
lastData: websocketPayload([createServer({ id: 1, name: "alpha" })]),
});
expect(scrollTo).not.toHaveBeenCalled();
expect(scrollTo).not.toHaveBeenCalledWith({
top: 345,
left: 0,
behavior: "auto",
});
});
it("virtualizes large server lists instead of rendering every card", () => {
const servers = Array.from({ length: 2000 }, (_, index) =>
createServer({ id: index + 1, name: `server-${index + 1}` }),
);
renderServerPage({
connected: true,
lastData: websocketPayload(servers),
});
expect(screen.getByTestId("server-overview")).toHaveTextContent(
"2000:2000:0",
);
expect(screen.getAllByTestId("server-card").length).toBeLessThan(2000);
expect(screen.getAllByTestId("server-card").length).toBeGreaterThan(0);
});
it("toggles map and service tracker controls when service data exists", async () => {