Files
Netcatty/components/ConnectionLogsManager.test.tsx
T
陈大猫 c8c4b14938 feat(remote-desktop): built-in VNC & RDP support, multi-monitor/RDPDR, telemetry, and Catty Computer Use (#4463)
* feat(remote-desktop): add built-in VNC and RDP support, JumpServer RDP, AI vision, monitoring, and recordings

* fix(build): move ironrdp-web patches out of patch-package directory

* perf(remote-desktop): coalesce pointer/snip events, zero-copy VNC paint, and memoize views

* fix(remote-desktop): prevent StrictMode WS one-time token race and improve new-host protocol switch

* style(remote-desktop): align toolbar height to 36px, refine overlays, and complete zh-CN/en i18n

* fix(rdp): fallback to TLS 1.2 kRSA when Electron BoringSSL rejects Windows RDP cert KEY_USAGE_BIT_INCORRECT

* feat(remote-desktop): responsive toolbar overflow, fix RDP HiDPI scaling, add Cmd-to-Ctrl, VNC refresh, and protocol-aware keys

* feat(remote-desktop): add RDP multi-monitor/RDPDR, telemetry, AI Computer Use, VNC upgrades, and perf hardening
2026-11-26 23:46:58 +08:00

85 lines
2.7 KiB
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import React from "react";
import { renderToStaticMarkup } from "react-dom/server";
import { I18nProvider } from "../application/i18n/I18nProvider.tsx";
import type { ConnectionLog } from "../domain/models/history.ts";
import { TooltipProvider } from "./ui/tooltip.tsx";
import ConnectionLogsManager, {
formatRecordingBytes,
formatRecordingDuration,
} from "./ConnectionLogsManager.tsx";
const renderWithI18n = (node: React.ReactElement) =>
renderToStaticMarkup(
<I18nProvider locale="en">
<TooltipProvider>{node}</TooltipProvider>
</I18nProvider>,
);
test("formatRecordingDuration and formatRecordingBytes format human-readable pills", () => {
assert.equal(formatRecordingDuration(0), "00:00");
assert.equal(formatRecordingDuration(134_000), "02:14");
assert.equal(formatRecordingDuration(3_661_000), "1:01:01");
assert.equal(formatRecordingBytes(0), "");
assert.equal(formatRecordingBytes(512), "512 B");
assert.equal(formatRecordingBytes(4_404_019), "4.2 MB");
});
test("ConnectionLogsManager renders RDP/VNC icons and compact recording pill when recordingId is present", () => {
const logs: ConnectionLog[] = [
{
id: "log-rdp-rec",
hostId: "h-1",
hostLabel: "Windows Prod",
hostname: "10.0.0.10",
username: "Administrator",
protocol: "rdp",
startTime: 1_700_000_000_000,
endTime: 1_700_000_134_000,
localUsername: "alice",
localHostname: "macbook",
saved: true,
recordingId: "123e4567-e89b-12d3-a456-426614174000",
recordingMimeType: "video/webm;codecs=vp9,opus",
recordingDurationMs: 134_000,
recordingBytes: 4_404_019,
recordingHasAudio: true,
},
{
id: "log-vnc-plain",
hostId: "h-2",
hostLabel: "Linux Desktop",
hostname: "10.0.0.20",
username: "",
protocol: "vnc",
startTime: 1_699_999_000_000,
endTime: 1_699_999_060_000,
localUsername: "alice",
localHostname: "macbook",
saved: false,
},
];
const markup = renderWithI18n(
React.createElement(ConnectionLogsManager, {
logs,
hosts: [],
onToggleSaved: () => {},
onDelete: () => {},
onClearUnsaved: () => {},
onOpenLogView: () => {},
}),
);
assert.match(markup, /Windows Prod/);
assert.match(markup, /Linux Desktop/);
assert.match(markup, /data-recording-badge="123e4567-e89b-12d3-a456-426614174000"/);
assert.match(markup, /02:14 · 4\.2 MB/);
assert.match(markup, /vnc, 10\.0\.0\.20/);
assert.match(markup, /bg-blue-500\/15 text-blue-600/);
assert.match(markup, /bg-teal-500\/15 text-teal-600/);
});