This repository has been archived on 2026-10-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
maestro/web/src/paths.test.ts
T
Miguel PalhasandClaude Opus 5 c9cfdb5668 feat(maestro): one-word handles, quieter project boxes
Session handles are one word from a single 218-entry list — instruments,
forms, notation and theory, tempo and dynamics — replacing the
adjective-noun pair. A batch is shuffled, so it repeats only once the
wordlist runs out.

Project boxes show the parent directory instead of the full path: the
last segment is already the name line above it. The last command is gone
from the box, and picking a project no longer pre-selects it — the
directory and what runs in it are independent choices. Both changes land
in the TUI picker too, which mirrors the web form's rules.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-31 22:40:49 +01:00

48 lines
1.5 KiB
TypeScript

import { describe, expect, it } from "vitest";
import { longestCommonPrefix, parentDir, splitPath } from "./paths.js";
describe("splitPath", () => {
it("splits on the last slash, keeping it with the directory", () => {
expect(splitPath("/home/n/wo")).toEqual({ dir: "/home/n/", prefix: "wo" });
expect(splitPath("/home/n/")).toEqual({ dir: "/home/n/", prefix: "" });
});
it("treats a slash-free value as all prefix", () => {
expect(splitPath("work")).toEqual({ dir: "", prefix: "work" });
expect(splitPath("")).toEqual({ dir: "", prefix: "" });
});
});
describe("longestCommonPrefix", () => {
it("returns the shared head", () => {
expect(longestCommonPrefix(["maestro", "maestro-web"])).toBe("maestro");
expect(longestCommonPrefix(["abc"])).toBe("abc");
});
it("is empty when nothing is shared", () => {
expect(longestCommonPrefix(["abc", "xyz"])).toBe("");
expect(longestCommonPrefix([])).toBe("");
});
it("preserves on-disk casing rather than folding it", () => {
expect(longestCommonPrefix(["Alpha", "alpha"])).toBe("");
});
});
describe("parentDir", () => {
it("drops the last segment", () => {
expect(parentDir("/home/user/tea/maestro")).toBe("/home/user/tea");
expect(parentDir("/home/user/tea/maestro/")).toBe("/home/user/tea");
});
it("keeps the root for a top-level path", () => {
expect(parentDir("/maestro")).toBe("/");
expect(parentDir("/")).toBe("/");
});
it("is empty for a bare name", () => {
expect(parentDir("maestro")).toBe("");
});
});