Files
NetMesh/electron/startupMemoryGuards.test.cjs
zhaolei 3c72efcb7f
Some checks failed
build-packages / resolve bundled mosh-client (push) Has been cancelled
build-packages / resolve bundled et-client (push) Has been cancelled
build-packages / build-macos (push) Has been cancelled
build-packages / build-windows (push) Has been cancelled
build-packages / build-linux-x64 (push) Has been cancelled
build-packages / build-linux-arm64 (push) Has been cancelled
build-packages / release (push) Has been cancelled
build-packages / update Nix release metadata (push) Has been cancelled
build-packages / bump homebrew tap (push) Has been cancelled
test / lint-and-test (push) Has been cancelled
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
build-et-binaries / build-linux-x64 (push) Has been cancelled
build-et-binaries / build-linux-arm64 (push) Has been cancelled
build-et-binaries / build-macos-universal (push) Has been cancelled
build-et-binaries / build-windows-x64 (push) Has been cancelled
build-et-binaries / release (push) Has been cancelled
[Init] Initial commit - NetMesh terminal manager
2026-09-13 18:24:01 +08:00

72 lines
2.8 KiB
JavaScript

const assert = require('node:assert/strict');
const { readFileSync } = require('node:fs');
const path = require('node:path');
const test = require('node:test');
const root = __dirname;
function read(relativePath) {
return readFileSync(path.join(root, relativePath), 'utf8');
}
const WINDOW_SOURCES_WITH_SPELLCHECK = [
'bridges/windowManager/mainWindow.cjs',
'bridges/windowManager/settingsWindow.cjs',
'bridges/windowManager/terminalPopupWindow.cjs',
'bridges/globalShortcutBridge.cjs',
'bridges/windowManager/externalWindows.cjs',
'plugins/contributionIconRasterizer.cjs',
];
test('BrowserWindow webPreferences disable spellcheck for app windows', () => {
for (const relativePath of WINDOW_SOURCES_WITH_SPELLCHECK) {
const source = read(relativePath);
assert.match(
source,
/webPreferences:\s*\{[\s\S]*?spellcheck:\s*false/,
relativePath,
);
}
});
test('default session spell checker is disabled after ready', () => {
const source = read('main.cjs');
assert.match(source, /setSpellCheckerEnabled\?\.\(false\)/);
assert.match(source, /app\.whenReady\(\)\.then\(/);
});
test('SpareRendererForSitePerProcess is disabled via command-line switch', () => {
const source = read('main.cjs');
assert.match(
source,
/appendSwitch\(\s*["']disable-features["']\s*,\s*["']SpareRendererForSitePerProcess["']\s*\)/,
);
});
test('settings prewarm is off by default and only runs behind NETCATTY_PREWARM_SETTINGS=1', () => {
const source = read('main.cjs');
assert.match(source, /NETCATTY_PREWARM_SETTINGS\s*===\s*["']1["']/);
assert.match(source, /setTimeout\(\s*\(\)\s*=>\s*\{[\s\S]*?prewarmSettingsWindow[\s\S]*?\},\s*15000\s*\)/);
assert.doesNotMatch(source, /setTimeout\(\s*\(\)\s*=>\s*\{[\s\S]*?prewarmSettingsWindow[\s\S]*?\},\s*3000\s*\)/);
});
test('aggressive GPU switches are gated by NETCATTY_COMPAT_GPU and keep both ignore aliases', () => {
const source = read('main.cjs');
assert.match(source, /NETCATTY_COMPAT_GPU\s*!==\s*["']1["']/);
assert.match(source, /appendSwitch\(\s*["']ignore-gpu-blocklist["']\s*\)/);
assert.match(source, /appendSwitch\(\s*["']ignore-gpu-blacklist["']\s*\)/);
const gateIdx = source.indexOf('NETCATTY_COMPAT_GPU');
const blocklistIdx = source.indexOf('ignore-gpu-blocklist');
const blacklistIdx = source.indexOf('ignore-gpu-blacklist');
assert.ok(gateIdx >= 0 && blocklistIdx > gateIdx && blacklistIdx > gateIdx);
});
test('backgroundThrottling:false stays on terminal windows only, not settings', () => {
const main = read('bridges/windowManager/mainWindow.cjs');
const popup = read('bridges/windowManager/terminalPopupWindow.cjs');
const settings = read('bridges/windowManager/settingsWindow.cjs');
assert.match(main, /backgroundThrottling:\s*false/);
assert.match(popup, /backgroundThrottling:\s*false/);
assert.doesNotMatch(settings, /backgroundThrottling:\s*false/);
});