Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 isBaseThreadRoute,
5 resolveFileSelectionNavigationAction,
6 resolveThreadSelectionNavigationAction,
7} from "./adaptive-navigation";
8
9describe("isBaseThreadRoute", () => {
10 it("recognizes only the thread detail route", () => {
11 expect(isBaseThreadRoute("/threads/environment/thread")).toBe(true);
12 expect(isBaseThreadRoute("/threads/environment/thread/")).toBe(true);
13 expect(isBaseThreadRoute("/threads/environment/thread/files")).toBe(false);
14 expect(isBaseThreadRoute("/threads/environment/thread/review")).toBe(false);
15 });
16});
17
18describe("resolveThreadSelectionNavigationAction", () => {
19 it("updates params when a persistent sidebar selects a peer thread", () => {
20 expect(
21 resolveThreadSelectionNavigationAction({
22 usesSplitView: true,
23 pathname: "/threads/environment/thread",
24 }),
25 ).toBe("set-params");
26 });
27
28 it("replaces nested thread content when a persistent sidebar selects a peer", () => {
29 expect(
30 resolveThreadSelectionNavigationAction({
31 usesSplitView: true,
32 pathname: "/threads/environment/thread/files/path",
33 }),
34 ).toBe("replace");
35 });
36
37 it("pushes from Home so the back stack survives collapsing to compact", () => {
38 expect(
39 resolveThreadSelectionNavigationAction({
40 usesSplitView: true,
41 pathname: "/",
42 }),
43 ).toBe("push");
44 });
45
46 it("pushes compact list selections onto the native stack", () => {
47 expect(
48 resolveThreadSelectionNavigationAction({
49 usesSplitView: false,
50 pathname: "/threads/environment/thread",
51 }),
52 ).toBe("push");
53 });
54});
55
56describe("resolveFileSelectionNavigationAction", () => {
57 it("replaces the wide file browser with the selected preview", () => {
58 expect(resolveFileSelectionNavigationAction({ hasPersistentFileInspector: true })).toBe(
59 "replace",
60 );
61 });
62
63 it("pushes a preview above the compact file browser", () => {
64 expect(resolveFileSelectionNavigationAction({ hasPersistentFileInspector: false })).toBe(
65 "push",
66 );
67 });
68});