release(main): 同步 dev 最新候选改动
Storage Persistence Guard / storage-persistence-audit (push) Has been cancelled
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
Client Quality Gates / Shared client and Web (pull_request) Has been cancelled
Client Quality Gates / macOS Desktop (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (push) Has been cancelled
Client Quality Gates / Shared client and Web (push) Has been cancelled
Client Quality Gates / macOS Desktop (push) Has been cancelled
Client Quality Gates / Shared client and Web (pull_request) Has been cancelled
Client Quality Gates / macOS Desktop (pull_request) Has been cancelled
Storage Persistence Guard / storage-persistence-audit (pull_request) Has been cancelled
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
canMoveWorkspaceTabHistory,
|
||||
createWorkspaceTabHistory,
|
||||
currentWorkspaceTabPath,
|
||||
moveWorkspaceTabHistory,
|
||||
recordWorkspaceTabPath,
|
||||
replaceWorkspaceTabPath,
|
||||
} from "./workspaceTabHistory";
|
||||
|
||||
describe("workspace tab history", () => {
|
||||
it("records full paths without duplicating the current entry", () => {
|
||||
const initial = createWorkspaceTabHistory("/subjects");
|
||||
const detail = recordWorkspaceTabPath(initial, "/subjects/subject-1?tab=ae");
|
||||
|
||||
expect(detail).toEqual({ entries: ["/subjects", "/subjects/subject-1?tab=ae"], index: 1 });
|
||||
expect(recordWorkspaceTabPath(detail, "/subjects/subject-1?tab=ae")).toBe(detail);
|
||||
});
|
||||
|
||||
it("moves backward and forward without adding entries", () => {
|
||||
const detail = recordWorkspaceTabPath(createWorkspaceTabHistory("/subjects"), "/subjects/subject-1");
|
||||
const backward = moveWorkspaceTabHistory(detail, -1);
|
||||
const forward = moveWorkspaceTabHistory(backward?.history, 1);
|
||||
|
||||
expect(backward?.path).toBe("/subjects");
|
||||
expect(forward?.path).toBe("/subjects/subject-1");
|
||||
expect(canMoveWorkspaceTabHistory(backward?.history, -1)).toBe(false);
|
||||
expect(canMoveWorkspaceTabHistory(backward?.history, 1)).toBe(true);
|
||||
});
|
||||
|
||||
it("drops forward entries after a new navigation branch", () => {
|
||||
const detail = recordWorkspaceTabPath(createWorkspaceTabHistory("/subjects"), "/subjects/subject-1");
|
||||
const backward = moveWorkspaceTabHistory(detail, -1);
|
||||
const branch = recordWorkspaceTabPath(backward?.history, "/subjects/new");
|
||||
|
||||
expect(branch).toEqual({ entries: ["/subjects", "/subjects/new"], index: 1 });
|
||||
expect(canMoveWorkspaceTabHistory(branch, 1)).toBe(false);
|
||||
});
|
||||
|
||||
it("replaces canonical redirects without creating a backward loop", () => {
|
||||
const canonical = replaceWorkspaceTabPath(
|
||||
createWorkspaceTabHistory("/file-versions"),
|
||||
"/trial/study-1/documents",
|
||||
);
|
||||
|
||||
expect(canonical).toEqual({ entries: ["/trial/study-1/documents"], index: 0 });
|
||||
expect(canMoveWorkspaceTabHistory(canonical, -1)).toBe(false);
|
||||
expect(currentWorkspaceTabPath(canonical, "/file-versions")).toBe("/trial/study-1/documents");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user