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
146 lines
3.7 KiB
TypeScript
146 lines
3.7 KiB
TypeScript
import test from "node:test";
|
|
import assert from "node:assert/strict";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
import { vaultViewAreEqual } from "./VaultView.tsx";
|
|
|
|
const vaultViewSource = readFileSync(
|
|
new URL("./VaultView.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
const vaultViewLayoutSource = readFileSync(
|
|
new URL("./vault/VaultViewLayout.tsx", import.meta.url),
|
|
"utf8",
|
|
);
|
|
|
|
const baseProps = {
|
|
hosts: [],
|
|
keys: [],
|
|
identities: [],
|
|
proxyProfiles: [],
|
|
snippets: [],
|
|
snippetPackages: [],
|
|
customGroups: [],
|
|
knownHosts: [],
|
|
sessions: [],
|
|
managedSources: [],
|
|
groupConfigs: {},
|
|
terminalThemeId: "default",
|
|
terminalFontSize: 14,
|
|
navigateToSection: null,
|
|
};
|
|
|
|
test("VaultView re-renders when an external section navigation request changes", () => {
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
baseProps as never,
|
|
{ ...baseProps, navigateToSection: "snippets" } as never,
|
|
),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("VaultView memo does not depend on shellHistory prop identity", () => {
|
|
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", () => {
|
|
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", () => {
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
baseProps as never,
|
|
{
|
|
...baseProps,
|
|
terminalSettings: {
|
|
verifyHostKeys: false,
|
|
},
|
|
} as never,
|
|
),
|
|
false,
|
|
);
|
|
});
|
|
|
|
test("notes are not VaultView props — the notes section reads notesStore", () => {
|
|
// Note edits must not churn the App vault domain bag, so VaultView neither
|
|
// receives notes nor compares them.
|
|
for (const removed of [
|
|
"notes:",
|
|
"noteGroups:",
|
|
"onUpdateNotes:",
|
|
"onUpdateNoteGroups:",
|
|
]) {
|
|
assert.equal(
|
|
vaultViewSource.includes(removed),
|
|
false,
|
|
`VaultView must not declare ${removed}`,
|
|
);
|
|
}
|
|
assert.doesNotMatch(vaultViewSource, /prev\.notes === next\.notes/);
|
|
assert.match(
|
|
vaultViewLayoutSource,
|
|
/useNotesStore\(\{\s*enabled:\s*isActive,?\s*\}\)/,
|
|
);
|
|
assert.match(vaultViewLayoutSource, /function VaultNotesSection/);
|
|
});
|
|
|
|
test("connectionLogs are not VaultView props — the logs section reads connectionLogsStore", () => {
|
|
for (const removed of [
|
|
"connectionLogs:",
|
|
"onToggleConnectionLogSaved:",
|
|
"onDeleteConnectionLog:",
|
|
"onClearUnsavedConnectionLogs:",
|
|
]) {
|
|
assert.equal(
|
|
vaultViewSource.includes(removed),
|
|
false,
|
|
`VaultView must not declare ${removed}`,
|
|
);
|
|
}
|
|
// The section-gated connectionLogs memo escape hatch is gone with the prop.
|
|
assert.equal(vaultViewSource.includes("syncVaultViewMemoSection"), false);
|
|
assert.equal(vaultViewSource.includes("vaultViewLatestConnectionLogs"), false);
|
|
assert.match(vaultViewLayoutSource, /useConnectionLogsStore\(\)/);
|
|
assert.match(vaultViewLayoutSource, /function VaultConnectionLogsSection/);
|
|
});
|
|
|
|
test("notes and connectionLogs churn cannot re-render VaultView", () => {
|
|
// Even if a caller smuggles them in, areEqual ignores both.
|
|
assert.equal(
|
|
vaultViewAreEqual(
|
|
{ ...baseProps, notes: [], connectionLogs: [] } as never,
|
|
{
|
|
...baseProps,
|
|
notes: [{ id: "n1" }],
|
|
connectionLogs: [{ id: "log-1" }],
|
|
} as never,
|
|
),
|
|
true,
|
|
);
|
|
});
|