Open History to see the last commit
1import { describe, expect, it } from "vite-plus/test";
2
3import {
4 alignListPaneToHinge,
5 deriveLayout,
6 deriveThreadFeedInitialContentInset,
7 deriveThreadWorkLogSizing,
8 deriveWorkspacePaneLayout,
9 isPrimarySidebarPinned,
10} from "./layout";
11
12describe("thread work-log text sizing", () => {
13 it.each([
14 { baseFontSize: 16, fontScale: 1.25, estimatedRowHeight: 28 },
15 { baseFontSize: 22, fontScale: 2, estimatedRowHeight: 52 },
16 ])(
17 "measures accessibility text instead of locking it to the estimate: %j",
18 ({ estimatedRowHeight, ...settings }) => {
19 expect(deriveThreadWorkLogSizing(settings)).toMatchObject({
20 estimatedRowHeight,
21 fixedRowHeight: undefined,
22 });
23 },
24 );
25
26 it("invalidates native text measurements even when the minimum row height is unchanged", () => {
27 const original = deriveThreadWorkLogSizing({ baseFontSize: 16, fontScale: 1 });
28 for (const settings of [
29 { baseFontSize: 16, fontScale: 1.1 },
30 { baseFontSize: 17, fontScale: 1 },
31 ]) {
32 const resized = deriveThreadWorkLogSizing(settings);
33 expect(resized.estimatedRowHeight).toBe(original.estimatedRowHeight);
34 expect(resized.textSizeKey).not.toBe(original.textSizeKey);
35 }
36 });
37});
38
39describe("deriveThreadFeedInitialContentInset", () => {
40 // regression: #5585 land the first thread open above the composer on Android
41 it("does not double native iOS insets", () => {
42 expect(
43 deriveThreadFeedInitialContentInset({
44 platform: "ios",
45 usesNativeAutomaticInsets: true,
46 bottomContentInset: 174,
47 }),
48 ).toBeUndefined();
49 });
50});
51
52describe("isPrimarySidebarPinned", () => {
53 // regression: #20406 sidebar toggle works on iPad and iPhone Duo
54 it("keeps compact native roots pinned so search cannot hide the sidebar for a later split", () => {
55 expect(
56 isPrimarySidebarPinned({ pathname: "/", nativeWorkspace: true, usesSplitView: false }),
57 ).toBe(true);
58 });
59});
60
61describe("deriveWorkspacePaneLayout", () => {
62 it("keeps an explicitly hidden thread sidebar hidden when the file inspector is visible", () => {
63 const layout = deriveLayout({ width: 1_024, height: 1_366 });
64
65 expect(
66 deriveWorkspacePaneLayout({
67 layout,
68 viewportWidth: 1_024,
69 primarySidebarPreferredVisible: false,
70 auxiliaryPanePreferredVisible: true,
71 auxiliaryPaneRole: "inspector",
72 }),
73 ).toMatchObject({
74 primarySidebarVisible: false,
75 primarySidebarSuppressedByAuxiliary: false,
76 auxiliaryPaneVisible: true,
77 });
78 });
79});
80
81describe("alignListPaneToHinge", () => {
82 const layout = deriveLayout({ width: 852, height: 880 });
83
84 it("keeps the default split when either side of the hinge would be too narrow", () => {
85 const narrowList = {
86 layout,
87 hinge: { x: 300, width: 0 },
88 viewportWidth: 852,
89 leadingWidth: 96,
90 };
91 const narrowDetail = {
92 layout,
93 hinge: { x: 600, width: 0 },
94 viewportWidth: 852,
95 leadingWidth: 0,
96 };
97 expect(alignListPaneToHinge(narrowList)).toBe(layout);
98 expect(alignListPaneToHinge(narrowDetail)).toBe(layout);
99 });
100});