[Init] Initial commit - NetMesh terminal manager
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
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
This commit is contained in:
88
application/state/ymodemFileMemory.test.ts
Normal file
88
application/state/ymodemFileMemory.test.ts
Normal file
@@ -0,0 +1,88 @@
|
||||
import test from "node:test";
|
||||
import assert from "node:assert/strict";
|
||||
|
||||
import * as storageKeys from "../../infrastructure/config/storageKeys.ts";
|
||||
import { getRememberedYmodemSendDefaultPath, rememberYmodemSendFilePath } from "./ymodemFileMemory.ts";
|
||||
|
||||
type TestStore = {
|
||||
readString: (key: string) => string | null;
|
||||
writeString: (key: string, value: string) => boolean;
|
||||
};
|
||||
|
||||
const createStore = (initial: Record<string, string> = {}): {
|
||||
store: TestStore;
|
||||
values: Map<string, string>;
|
||||
} => {
|
||||
const values = new Map(Object.entries(initial));
|
||||
return {
|
||||
store: {
|
||||
readString: (key: string) => values.get(key) ?? null,
|
||||
writeString: (key: string, value: string) => {
|
||||
values.set(key, value);
|
||||
return true;
|
||||
},
|
||||
},
|
||||
values,
|
||||
};
|
||||
};
|
||||
|
||||
test("uses the remembered YMODEM send directory as the file picker default path", () => {
|
||||
assert.equal(
|
||||
storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR,
|
||||
"netcatty_terminal_ymodem_send_dir_v1",
|
||||
);
|
||||
|
||||
const { store } = createStore({
|
||||
[storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR]: "/firmware/releases",
|
||||
});
|
||||
|
||||
assert.equal(getRememberedYmodemSendDefaultPath(store), "/firmware/releases");
|
||||
});
|
||||
|
||||
test("preserves valid remembered directory whitespace", () => {
|
||||
const { store } = createStore({
|
||||
[storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR]: "/firmware/releases ",
|
||||
});
|
||||
|
||||
assert.equal(getRememberedYmodemSendDefaultPath(store), "/firmware/releases ");
|
||||
});
|
||||
|
||||
test("remembers the directory containing a selected YMODEM send file", () => {
|
||||
const { store, values } = createStore();
|
||||
|
||||
assert.equal(rememberYmodemSendFilePath("/firmware/releases/device.bin", store), true);
|
||||
assert.equal(
|
||||
values.get(storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR),
|
||||
"/firmware/releases",
|
||||
);
|
||||
});
|
||||
|
||||
test("keeps POSIX backslashes as part of the selected file name", () => {
|
||||
const { store, values } = createStore();
|
||||
|
||||
assert.equal(rememberYmodemSendFilePath("/firmware/releases\\device.bin", store), true);
|
||||
assert.equal(
|
||||
values.get(storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR),
|
||||
"/firmware",
|
||||
);
|
||||
});
|
||||
|
||||
test("remembers Windows-style YMODEM send directories", () => {
|
||||
const { store, values } = createStore();
|
||||
|
||||
assert.equal(rememberYmodemSendFilePath("C:\\Users\\catty\\device.bin", store), true);
|
||||
assert.equal(
|
||||
values.get(storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR),
|
||||
"C:\\Users\\catty",
|
||||
);
|
||||
});
|
||||
|
||||
test("ignores blank remembered paths and selected file names without a parent directory", () => {
|
||||
const { store, values } = createStore({
|
||||
[storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR]: " ",
|
||||
});
|
||||
|
||||
assert.equal(getRememberedYmodemSendDefaultPath(store), undefined);
|
||||
assert.equal(rememberYmodemSendFilePath("device.bin", store), false);
|
||||
assert.equal(values.get(storageKeys.STORAGE_KEY_TERMINAL_YMODEM_SEND_DIR), " ");
|
||||
});
|
||||
Reference in New Issue
Block a user