mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-20 07:04:53 +00:00
Split the main-window mega bag into domain-scoped AppView slices so Vault, terminal, chrome, dialogs, and mounts only re-render when their slice identity changes. Drive tab titles/coding-CLI icons through sessionPresentationStore (store-only live updates + orphan map overlay), retain presentation-stable sessions for domain memos, stabilize AI panel context Maps with structural equal/retain, and keep shell history on shellHistoryStore so Vault host lists ignore history-only churn.
147 lines
3.1 KiB
TypeScript
147 lines
3.1 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
|
|
import { vaultViewAreEqual } from "./VaultView.tsx";
|
|
|
|
test("VaultView re-renders when an external section navigation request changes", () => {
|
|
const baseProps = {
|
|
hosts: [],
|
|
keys: [],
|
|
identities: [],
|
|
proxyProfiles: [],
|
|
snippets: [],
|
|
snippetPackages: [],
|
|
notes: [],
|
|
noteGroups: [],
|
|
customGroups: [],
|
|
knownHosts: [],
|
|
connectionLogs: [],
|
|
sessions: [],
|
|
managedSources: [],
|
|
groupConfigs: {},
|
|
terminalThemeId: "default",
|
|
terminalFontSize: 14,
|
|
navigateToSection: null,
|
|
};
|
|
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
baseProps as never,
|
|
{ ...baseProps, navigateToSection: "snippets" } as never,
|
|
),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("VaultView memo does not depend on shellHistory prop identity", () => {
|
|
const baseProps = {
|
|
hosts: [],
|
|
keys: [],
|
|
identities: [],
|
|
proxyProfiles: [],
|
|
snippets: [],
|
|
snippetPackages: [],
|
|
notes: [],
|
|
noteGroups: [],
|
|
customGroups: [],
|
|
knownHosts: [],
|
|
connectionLogs: [],
|
|
sessions: [],
|
|
managedSources: [],
|
|
groupConfigs: {},
|
|
terminalThemeId: "default",
|
|
terminalFontSize: 14,
|
|
navigateToSection: null,
|
|
};
|
|
// History-only updates must not be part of VaultView equality (store path).
|
|
assert.equal(
|
|
vaultViewAreEqual(baseProps as never, { ...baseProps } as never),
|
|
true,
|
|
);
|
|
assert.equal(
|
|
Object.prototype.hasOwnProperty.call(baseProps, "shellHistory"),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("VaultView re-renders when proxy profiles change", () => {
|
|
const baseProps = {
|
|
hosts: [],
|
|
keys: [],
|
|
identities: [],
|
|
proxyProfiles: [],
|
|
snippets: [],
|
|
snippetPackages: [],
|
|
notes: [],
|
|
noteGroups: [],
|
|
customGroups: [],
|
|
knownHosts: [],
|
|
connectionLogs: [],
|
|
sessions: [],
|
|
managedSources: [],
|
|
groupConfigs: {},
|
|
terminalThemeId: "default",
|
|
terminalFontSize: 14,
|
|
navigateToSection: null,
|
|
};
|
|
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
baseProps as never,
|
|
{
|
|
...baseProps,
|
|
proxyProfiles: [
|
|
{
|
|
id: "proxy-1",
|
|
label: "Proxy",
|
|
config: { type: "http", host: "proxy.example.com", port: 3128 },
|
|
createdAt: 1,
|
|
},
|
|
],
|
|
} as never,
|
|
),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("VaultView re-renders when host-key verification setting changes", () => {
|
|
const baseProps = {
|
|
hosts: [],
|
|
keys: [],
|
|
identities: [],
|
|
proxyProfiles: [],
|
|
snippets: [],
|
|
snippetPackages: [],
|
|
notes: [],
|
|
noteGroups: [],
|
|
customGroups: [],
|
|
knownHosts: [],
|
|
connectionLogs: [],
|
|
sessions: [],
|
|
managedSources: [],
|
|
groupConfigs: {},
|
|
terminalThemeId: "default",
|
|
terminalFontSize: 14,
|
|
navigateToSection: null,
|
|
terminalSettings: {
|
|
verifyHostKeys: true,
|
|
keepaliveInterval: 30,
|
|
keepaliveCountMax: 10,
|
|
},
|
|
};
|
|
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
baseProps as never,
|
|
{
|
|
...baseProps,
|
|
terminalSettings: {
|
|
...baseProps.terminalSettings,
|
|
verifyHostKeys: false,
|
|
},
|
|
} as never,
|
|
),
|
|
false,
|
|
);
|
|
});
|