Files
Netcatty/components/terminal/TerminalServerStats.test.ts
T
08009d4ce0 feat(terminal): show GPU utilization next to CPU in server stats strip (#3411)
* fix(#3410): automated AI fix

* fix(terminal): bound GPU stats queries and complete Chinese labels

* fix(terminal): declare optional GPU fields on stats bridge

* test(terminal): keep GPU fixtures in managed temporary storage

* fix(terminal): preserve unknown GPU memory totals

---------

Co-authored-by: netcatty-bot <308658023+netcatty-bot@users.noreply.github.com>
Co-authored-by: bincxz <16399091+binaricat@users.noreply.github.com>
2026-09-18 14:10:06 +08:00

32 lines
1.1 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import { readFileSync } from "node:fs";
test("CPU per-core stats list can scroll when many cores are reported", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
assert.match(
source,
/className="grid gap-1\.5 max-h-\[\d+px\] overflow-y-auto/,
);
});
test("server stats stay subscribed while the terminal is in the background", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
assert.doesNotMatch(source, /usePaneVisible/);
assert.doesNotMatch(source, /isVisible,/);
});
test("GPU chip only renders when the remote reports GPU utilization", () => {
const source = readFileSync(new URL("./TerminalServerStats.tsx", import.meta.url), "utf8");
// Conditional render — hosts without nvidia-smi must not show an empty GPU chip.
assert.match(source, /\{serverStats\.gpu !== null && \(/);
// Sits directly after the CPU chip, before the memory chip.
assert.match(
source,
/terminal\.serverStats\.gpu[\s\S]{0,2000}terminal\.serverStats\.memory/,
);
});