mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-27 11:56:20 +00:00
* 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
193 lines
6.1 KiB
TypeScript
193 lines
6.1 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';
|
|
import { TooltipProvider } from '../ui/tooltip';
|
|
import { RemoteDesktopToolbar, type RemoteDesktopToolbarProps } from './RemoteDesktopToolbar';
|
|
|
|
function renderToolbar(overrides: Partial<RemoteDesktopToolbarProps> = {}): string {
|
|
const baseProps: RemoteDesktopToolbarProps = {
|
|
protocol: 'rdp',
|
|
hostLabel: 'prod-win-01',
|
|
status: 'connected',
|
|
isFullscreen: false,
|
|
keyboardGrabActive: false,
|
|
onToggleKeyboardGrab: () => {},
|
|
onSendSpecialKey: () => {},
|
|
onTypeClipboard: () => {},
|
|
displayMode: 'dynamic',
|
|
onChangeDisplayMode: () => {},
|
|
clipboardSyncEnabled: true,
|
|
onToggleClipboardSync: () => {},
|
|
quality: 'auto',
|
|
onChangeQuality: () => {},
|
|
viewOnly: false,
|
|
onToggleViewOnly: () => {},
|
|
onScreenshotCopy: () => {},
|
|
onScreenshotSave: () => {},
|
|
onToggleFullscreen: () => {},
|
|
onReconnect: () => {},
|
|
onDisconnect: () => {},
|
|
...overrides,
|
|
};
|
|
return renderToStaticMarkup(
|
|
<I18nProvider locale="en">
|
|
<TooltipProvider>
|
|
<RemoteDesktopToolbar {...baseProps} />
|
|
</TooltipProvider>
|
|
</I18nProvider>,
|
|
);
|
|
}
|
|
|
|
test('RemoteDesktopToolbar does not expose SFTP button on graphical remote desktop toolbar', () => {
|
|
const withoutSftp = renderToolbar();
|
|
assert.doesNotMatch(withoutSftp, /data-testid="remote-desktop-sftp-btn"/);
|
|
|
|
const withSftpProp = renderToolbar({ onOpenSftp: () => {}, isSftpOpen: true });
|
|
assert.doesNotMatch(withSftpProp, /data-testid="remote-desktop-sftp-btn"/);
|
|
});
|
|
|
|
test('RemoteDesktopToolbar renders live clipboard transfer progress pills for all phases', () => {
|
|
const staged = renderToolbar({
|
|
clipboardTransfer: {
|
|
id: 't1',
|
|
direction: 'upload',
|
|
phase: 'staged',
|
|
fileName: 'report.pdf',
|
|
fileCount: 2,
|
|
transferredBytes: 0,
|
|
totalBytes: 2048,
|
|
percent: 0,
|
|
message: 'Ready to paste 2 files on remote (Ctrl+V)',
|
|
},
|
|
});
|
|
assert.match(staged, /data-testid="rdp-clipboard-transfer-pill"/);
|
|
assert.match(staged, /data-transfer-phase="staged"/);
|
|
assert.match(staged, /2 file\(s\) · Ctrl\+V/);
|
|
|
|
const transferring = renderToolbar({
|
|
clipboardTransfer: {
|
|
id: 't2',
|
|
direction: 'download',
|
|
phase: 'transferring',
|
|
fileName: 'dump.log',
|
|
fileCount: 1,
|
|
transferredBytes: 512,
|
|
totalBytes: 1024,
|
|
percent: 50,
|
|
message: 'Downloading dump.log (50%)',
|
|
},
|
|
});
|
|
assert.match(transferring, /data-transfer-phase="transferring"/);
|
|
assert.match(transferring, /dump\.log/);
|
|
assert.match(transferring, /50%/);
|
|
|
|
const completed = renderToolbar({
|
|
clipboardTransfer: {
|
|
id: 't3',
|
|
direction: 'upload',
|
|
phase: 'completed',
|
|
fileName: 'a.txt',
|
|
fileCount: 1,
|
|
transferredBytes: 100,
|
|
totalBytes: 100,
|
|
percent: 100,
|
|
message: 'Sent a.txt',
|
|
},
|
|
onDismissClipboardTransfer: () => {},
|
|
});
|
|
assert.match(completed, /data-transfer-phase="completed"/);
|
|
assert.match(completed, /Dismiss transfer status/);
|
|
});
|
|
|
|
test('RemoteDesktopToolbar renders Ask AI split button, privacy lock badge, and recording pill (including fullscreen)', () => {
|
|
const html = renderToolbar({
|
|
isFullscreen: true,
|
|
onAskAiFull: () => {},
|
|
onAskAiRegion: () => {},
|
|
onOpenAiChat: () => {},
|
|
aiReadBlocked: true,
|
|
onToggleAiReadBlocked: () => {},
|
|
isRecording: true,
|
|
recordingElapsedLabel: '02:14',
|
|
onToggleRecording: () => {},
|
|
});
|
|
|
|
assert.match(html, /data-testid="remote-desktop-ask-ai-btn"/);
|
|
assert.match(html, /data-testid="remote-desktop-ask-ai-menu"/);
|
|
assert.match(html, /AI screen reading blocked/);
|
|
assert.match(html, /data-testid="remote-desktop-record-btn"/);
|
|
assert.match(html, /data-recording="true"/);
|
|
assert.match(html, /02:14/);
|
|
});
|
|
|
|
test('RemoteDesktopToolbar renders monitor switcher, shared folders badge, and network quality pill', () => {
|
|
const rdpHtml = renderToolbar({
|
|
protocol: 'rdp',
|
|
monitorCount: 2,
|
|
activeMonitorIndex: 0,
|
|
onSelectActiveMonitor: () => {},
|
|
sharedFolders: [
|
|
{ id: 'sf-1', deviceId: 10, name: 'Projects', path: '/Users/dev/Projects', readOnly: false },
|
|
{ id: 'sf-2', deviceId: 11, name: 'Docs', path: '/Users/dev/Docs', readOnly: true },
|
|
],
|
|
onAddSharedFolder: () => {},
|
|
onRemoveSharedFolder: () => {},
|
|
onToggleSharedFolderReadOnly: () => {},
|
|
networkStats: {
|
|
sessionId: 's1',
|
|
protocol: 'rdp',
|
|
rttMs: 18,
|
|
rxBps: 128000,
|
|
txBps: 4096,
|
|
totalRxBytes: 2048000,
|
|
totalTxBytes: 64000,
|
|
ts: Date.now(),
|
|
},
|
|
});
|
|
|
|
assert.match(rdpHtml, /data-testid="rdp-monitor-switcher"/);
|
|
assert.match(rdpHtml, />All</);
|
|
assert.match(rdpHtml, />1</);
|
|
assert.match(rdpHtml, />2</);
|
|
assert.match(rdpHtml, /data-testid="rdp-shared-folders-btn"/);
|
|
assert.match(rdpHtml, />2</);
|
|
assert.match(rdpHtml, /data-testid="remote-desktop-network-pill"/);
|
|
assert.match(rdpHtml, /data-quality-tier="excellent"/);
|
|
assert.match(rdpHtml, /18ms/);
|
|
|
|
// VNC hides RDP-only monitor switcher & shared folders, keeps network quality pill
|
|
const vncHtml = renderToolbar({
|
|
protocol: 'vnc',
|
|
monitorCount: 2,
|
|
onSelectActiveMonitor: () => {},
|
|
onAddSharedFolder: () => {},
|
|
networkStats: {
|
|
sessionId: 's2',
|
|
protocol: 'vnc',
|
|
rttMs: 245,
|
|
rxBps: 50000,
|
|
txBps: 1000,
|
|
totalRxBytes: 500000,
|
|
totalTxBytes: 10000,
|
|
ts: Date.now(),
|
|
},
|
|
});
|
|
assert.doesNotMatch(vncHtml, /data-testid="rdp-monitor-switcher"/);
|
|
assert.doesNotMatch(vncHtml, /data-testid="rdp-shared-folders-btn"/);
|
|
assert.match(vncHtml, /data-testid="remote-desktop-network-pill"/);
|
|
assert.match(vncHtml, /data-quality-tier="poor"/);
|
|
assert.match(vncHtml, /245ms/);
|
|
});
|
|
|
|
test('RemoteDesktopToolbar disables Keyboard Grab while connecting', () => {
|
|
const connectingHtml = renderToolbar({
|
|
protocol: 'vnc',
|
|
status: 'connecting',
|
|
viewOnly: false,
|
|
keyboardGrabActive: false,
|
|
});
|
|
assert.match(connectingHtml, /<button[^>]*disabled=""[^>]*aria-label="Keys: Local"/);
|
|
});
|