Files
Netcatty/electron/plugins/terminalInterceptorMessages.test.cjs
T
陈大猫 67f8108713 feat(plugins): add reviewed privileged terminal data pipeline (#2402)
* feat(plugins): add privileged terminal data pipeline

* fix(plugins): harden terminal interceptor lifecycle

* fix(plugins): close terminal interceptor lifecycle gaps

* fix(plugins): preserve terminal interceptor state transitions

* fix(plugin): close terminal pipeline lifecycle gaps

* fix(plugin): harden terminal interceptor startup

* fix(plugin): isolate terminal output route attempts

* fix(plugin): isolate reused terminal sessions

* fix(plugin): harden terminal interceptor boundaries

* fix(plugin): harden terminal replay metadata

* fix(plugin): preserve terminal replay provenance

* fix(plugin): close terminal pipeline lifecycle races

* fix(plugin): harden terminal route handoff

* fix(plugin): contain terminal handoff failures

* fix(plugin): route terminal attachment through RPC

* fix(plugin): validate terminal attachment RPC

* fix(plugin): close unexpected runtime ports

* fix(plugin): canonicalize terminal data frames

* fix(plugin): close terminal pipeline lifecycle gaps

* fix(plugin): close terminal interceptor review gaps

* fix(plugin): harden terminal interceptor protocol handling

* fix(plugin): preserve terminal flow compatibility

* fix(plugin): preserve terminal protocol accounting

* fix(plugin): bound terminal interceptor lifecycle

* fix(plugin): close terminal interceptor review gaps

---------

Co-authored-by: ryan-wong-coder <wangsiyuan19990317@gmail.com>
2026-07-23 09:42:47 +08:00

48 lines
1.8 KiB
JavaScript

"use strict";
const assert = require("node:assert/strict");
const test = require("node:test");
const {
terminalInterceptorChoiceLabel,
terminalInterceptorIdentifier,
terminalInterceptorMessages,
} = require("./terminalInterceptorMessages.cjs");
test("terminal interceptor native prompts cover every application locale and fall back to English", () => {
for (const locale of ["en", "zh-CN", "zh-TW", "ru"]) {
const messages = terminalInterceptorMessages(locale);
assert.ok(messages.noInterceptor);
assert.ok(messages.selectTitle("input"));
assert.ok(messages.selectMessage("output"));
assert.ok(messages.warningTitle);
}
assert.equal(terminalInterceptorMessages("fr").noInterceptor, "No interceptor");
});
test("plugin-controlled native selection labels visibly escape control and bidi text", () => {
assert.equal(terminalInterceptorChoiceLabel({
pluginId: "com.example.safe",
pluginDisplayName: "safe\nname\u202e",
provider: { id: "com.example.input", label: "input\tfilter" },
}), "safe\\nname\\u202e (com.example.safe): input\\tfilter (com.example.input)");
assert.equal(terminalInterceptorIdentifier("provider\r\u2066"), "provider\\r\\u2066");
});
test("selection labels keep distinct valid provider identifiers visible in full", () => {
const shared = `com.example.${"a".repeat(170)}`;
const first = terminalInterceptorChoiceLabel({
pluginId: "com.example",
pluginDisplayName: "Plugin",
provider: { id: `${shared}.first`, label: "Filter" },
});
const second = terminalInterceptorChoiceLabel({
pluginId: "com.example",
pluginDisplayName: "Plugin",
provider: { id: `${shared}.other`, label: "Filter" },
});
assert.notEqual(first, second);
assert.match(first, /\.first\)$/u);
assert.match(second, /\.other\)$/u);
});