feat(FN-2921): merge fusion/fn-2921

- feat(FN-2921): complete Step 2 — apply filename-first truncation in change lists
- feat(FN-2921): complete Step 1 — prioritize filename-first path truncation

Fusion-Task-Id: FN-2921
This commit is contained in:
Fusion
2026-04-28 22:43:51 -07:00
committed by gsxdsm
parent fc837ad349
commit 83ad6e45ab
7 changed files with 33 additions and 19 deletions

View File

@@ -20,13 +20,11 @@ describe("truncateMiddle", () => {
expect(truncateMiddle(path, 60)).toBe(path);
});
it("truncates a long path from the middle", () => {
it("truncates a long path by prioritizing the filename suffix", () => {
const path = "packages/dashboard/app/components/TaskChangesTab.tsx";
const result = truncateMiddle(path, 30);
expect(result).toContain("...");
expect(result).toBe(".../TaskChangesTab.tsx");
expect(result.length).toBeLessThanOrEqual(30);
// Filename should be preserved
expect(result.endsWith("TaskChangesTab.tsx")).toBe(true);
});
it("preserves the full path when under maxLength", () => {
@@ -84,12 +82,11 @@ describe("truncateMiddle", () => {
expect(result).toContain("...");
});
it("preserves start portion when truncating", () => {
it("does not require preserving the start when filename suffix fits", () => {
const path = "packages/dashboard/app/components/TaskChangesTab.tsx";
const result = truncateMiddle(path, 35);
expect(result.startsWith("packages")).toBe(true);
expect(result).toContain("...");
expect(result.endsWith("TaskChangesTab.tsx")).toBe(true);
expect(result).toBe(".../TaskChangesTab.tsx");
expect(result.endsWith("/TaskChangesTab.tsx")).toBe(true);
});
it("works with paths that have dots but no slashes", () => {
@@ -103,4 +100,18 @@ describe("truncateMiddle", () => {
const result = truncateMiddle(path, 60);
expect(result.length).toBeLessThanOrEqual(60);
});
it("shows full filename for deeply nested paths when filename fits", () => {
const path = "a/b/c/d/e/f/Component.tsx";
const result = truncateMiddle(path, 20);
expect(result).toBe(".../Component.tsx");
expect(result.endsWith("/Component.tsx")).toBe(true);
});
it("preserves extension when filename fits", () => {
const path = "deeply/nested/another/path/verylongname.test.tsx";
const result = truncateMiddle(path, 24);
expect(result).toBe("...verylongname.test.tsx");
expect(result.endsWith(".test.tsx")).toBe(true);
});
});