fix SCUM player online freshness display

This commit is contained in:
npc0-hue
2026-08-27 10:12:23 +08:00
parent 9022cf0bea
commit 2937ece1bc
5 changed files with 21 additions and 8 deletions
+9 -1
View File
@@ -175,7 +175,8 @@ describe("SCUM plugin feature module", () => {
it("renders searchable user management from real collection values", () => {
const view = renderAndCollect();
expect(view.nodes).toContain("section:用户管理");
expect(view.texts).toContain("SCUM 用户真实记录");
expect(view.texts).not.toContain("SCUM 用户真实记录");
expect(view.texts).toEqual(expect.arrayContaining(["在线用户 ", "1 / 1"]));
expect(view.texts).toEqual(expect.arrayContaining(["用户名", "队伍", "状态", "最后活动", "操作"]));
expect(view.texts).not.toEqual(expect.arrayContaining(["Steam", "上次登录", "登录 IP", "概况"]));
expect(view.texts).not.toContain("筛选结果");
@@ -191,6 +192,13 @@ describe("SCUM plugin feature module", () => {
expect(view.texts.join("\n")).not.toContain("Fame 42");
});
it("expires online users after five minutes without activity", () => {
const staleAt = new Date(Date.now() - 5 * 60 * 1000 - 1).toISOString();
const view = renderAndCollect({ data: { ...surfaceData, players: [{ ...surfaceData.players[0], lastSeenAt: staleAt }] } });
expect(view.texts).toEqual(expect.arrayContaining(["在线用户 ", "0 / 1"]));
expect(view.texts).toContain("离线/未知");
});
it("prepares player attribute SQL execution through platform-to-Run remote access", async () => {
const player = { steamId: "76561198000000001", displayName: "Mira", stateVersion: "state-1", stamina: 12, dexterity: 4, intelligence: 8 };
const drafts = playerAttributeDrafts(player).map((draft) => draft.fieldKey === "stamina" ? { ...draft, after: "855" } : draft);