Skip to content
Source
Sign inSign up
pingdotgg/t3code
Open History to see the last commit

StyledDiffCodeView.browser.test.tsx

650 lines23.1 KB

1import {
2 CodeView,
3 FileDiff,
4 FileRenderer,
5 getSharedHighlighter,
6 type CodeViewItem,
7 type CodeViewScrollTarget,
8 type FileContents,
9} from "@pierre/diffs";
10import { useWorkerPool, type CodeViewProps } from "@pierre/diffs/react";
11import { WorkerPoolManager, type WorkerRequest, type WorkerResponse } from "@pierre/diffs/worker";
12import DiffsWorker from "@pierre/diffs/worker/worker.js?worker";
13import { getDiffLineStat, getRenderablePatch } from "../../lib/diffRendering";
14import {
15 act,
16 StrictMode,
17 useEffect,
18 useImperativeHandle,
19 useLayoutEffect,
20 useRef,
21 useState,
22 type ReactElement,
23 type Ref,
24} from "react";
25import { createRoot, type Root } from "react-dom/client";
26import { afterEach, beforeEach, describe, expect, it, vi } from "vite-plus/test";
27​
28const testState = vi.hoisted(() => ({
29 workers: [] as Worker[],
30 terminations: 0,
31 requests: [] as WorkerRequest[],
32 pools: new Map<WorkerPoolManager, Promise<void>>(),
33 renderPools: [] as (WorkerPoolManager | undefined)[],
34 failWorkers: false,
35 holdInitialization: false,
36 heldResponses: [] as (() => void)[],
37 onInitializationHeld: undefined as (() => void) | undefined,
38}));
39​
40vi.mock(import("../../hooks/useTheme"), async (original) => ({
41 ...(await original()),
42 useTheme: (() => ({ resolvedTheme: "dark" })) as never,
43}));
44​
45// Wraps Pierre's real worker so the suite can count workers, read requests and hold startup.
46// Vite's `?worker` export is a factory that returns a plain Worker, so this patches the instance.
47vi.mock("@pierre/diffs/worker/worker.js?worker", async (original) => {
48 const actual = await original<{ default: new () => Worker }>();
49 return {
50 ...actual,
51 default: function TestDiffsWorker() {
52 if (testState.failWorkers) throw new Error("Worker creation failed");
53 const worker = new actual.default();
54 testState.workers.push(worker);
55 const addEventListener = worker.addEventListener.bind(worker);
56 const postMessage = worker.postMessage.bind(worker);
57 const terminate = worker.terminate.bind(worker);
58 worker.addEventListener = (type: string, listener: EventListenerOrEventListenerObject) => {
59 if (type !== "message" || typeof listener !== "function") {
60 addEventListener(type, listener);
61 return;
62 }
63 addEventListener("message", (event) => {
64 const data = (event as MessageEvent<WorkerResponse>).data;
65 const deliver = () => listener(event);
66 if (
67 testState.holdInitialization &&
68 data.type === "success" &&
69 data.requestType === "initialize"
70 ) {
71 testState.heldResponses.push(deliver);
72 if (testState.heldResponses.length === 2) testState.onInitializationHeld?.();
73 } else {
74 deliver();
75 }
76 });
77 };
78 worker.postMessage = (message: WorkerRequest) => {
79 testState.requests.push(message);
80 postMessage(message);
81 };
82 worker.terminate = () => {
83 testState.terminations += 1;
84 terminate();
85 };
86 return worker;
87 },
88 };
89});
90​
91// Pierre's real viewer virtualizes into a shadow root; this stand-in renders each file through
92// the same worker pool and keeps the highlighted HTML readable.
93vi.mock(import("@pierre/diffs/react"), async (original) => ({
94 ...(await original()),
95 CodeView: ((props: CodeViewProps<undefined, undefined>) =>
96 props.items?.map((item) =>
97 item.type === "file" ? <FileOutput key={item.id} file={item.file} /> : null,
98 )) as never,
99}));
100​
101import { StyledDiffCodeView } from "./StyledDiffCodeView";
102import { useCodeViewFileReveal } from "./useCodeViewFileReveal";
103​
104function FileOutput({ file }: { file: FileContents }) {
105 const pool = useWorkerPool();
106 const [html, setHtml] = useState("");
107 useEffect(() => {
108 testState.renderPools.push(pool);
109 const renderer = new FileRenderer(
110 { theme: "pierre-dark", preferredHighlighter: "shiki-wasm" },
111 undefined,
112 render,
113 pool,
114 );
115 function render() {
116 const result = renderer.renderFile(file);
117 if (result) setHtml(renderer.renderFullHTML(result));
118 }
119 render();
120 return () => renderer.cleanUp();
121 }, [file, pool]);
122 return <pre data-code-file={file.name}>{html}</pre>;
124​
125const files = [
126 { name: "notes.txt", contents: "Plain text is ready.\n", cacheKey: "plain-text" },
127 { name: "answer.ts", contents: "const answer = 42;\n", cacheKey: "typescript" },
128] satisfies FileContents[];
129​
130function Views({ count }: { count: number }) {
131 const [draft, setDraft] = useState("Draft");
132 return (
133 <>
134 <button onClick={() => setDraft("Edited draft")}>{draft}</button>
135 {files.slice(0, count).map((file) => (
136 <StyledDiffCodeView key={file.name} items={[{ type: "file", id: file.name, file }]} />
137 ))}
138 </>
139 );
141​
142function renderViews(count: number) {
143 return (
144 <StrictMode>
145 <Views count={count} />
146 </StrictMode>
147 );
149​
150const roots: Root[] = [];
151​
152function mount(element: ReactElement) {
153 const container = document.createElement("div");
154 document.body.append(container);
155 const root = createRoot(container);
156 roots.push(root);
157 return {
158 root,
159 render: (next: ReactElement) => act(async () => root.render(next)),
160 initial: act(async () => root.render(element)),
161 };
163​
164async function unmountAll() {
165 for (const root of roots.splice(0)) await act(async () => root.unmount());
166 document.body.replaceChildren();
168​
169const codeFile = (name: string) =>
170 document.querySelector(`[data-code-file="${name}"]`)?.textContent ?? "";
171const loadingViews = () => document.querySelectorAll('[role="status"]').length;
172​
173describe("code-view worker lifecycle", () => {
174 beforeEach(() => {
175 testState.workers = [];
176 testState.terminations = 0;
177 testState.requests = [];
178 testState.pools.clear();
179 testState.renderPools = [];
180 testState.failWorkers = false;
181 testState.holdInitialization = false;
182 testState.heldResponses = [];
183 testState.onInitializationHeld = undefined;
184 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
185 // Pins the pool at two workers whatever machine runs the suite.
186 Object.defineProperty(navigator, "hardwareConcurrency", { configurable: true, value: 2 });
187 vi.useFakeTimers({ toFake: ["setTimeout", "clearTimeout"] });
188 const initialize = WorkerPoolManager.prototype.initialize;
189 vi.spyOn(WorkerPoolManager.prototype, "initialize").mockImplementation(function (
190 this: WorkerPoolManager,
191 ...args
192 ) {
193 const pending = initialize.apply(this, args);
194 testState.pools.set(this, pending);
195 return pending;
196 });
197 });
198​
199 afterEach(async () => {
200 await unmountAll();
201 await vi.runOnlyPendingTimersAsync();
202 vi.useRealTimers();
203 vi.restoreAllMocks();
204 vi.unstubAllGlobals();
205 delete (navigator as { hardwareConcurrency?: number }).hardwareConcurrency;
206 });
207​
208 it("starts on demand, keeps quick reopens warm, and expires the last closed pool", async () => {
209 const view = mount(renderViews(0));
210 await view.initial;
211 const button = document.querySelector("button")!;
212 expect(testState.workers).toHaveLength(0);
213 expect(testState.pools.size).toBe(0);
214 await act(async () => button.click());
215 await view.render(renderViews(1));
216 const pool = [...testState.pools.keys()][0]!;
217 await act(async () => testState.pools.get(pool));
218 expect(pool.isInitialized()).toBe(true);
219 expect(testState.workers).toHaveLength(2);
220 await vi.waitFor(() => expect(codeFile("notes.txt")).toContain("Plain text is ready."));
221 expect(testState.requests.filter((request) => request.type === "file")).toHaveLength(0);
222​
223 await view.render(renderViews(2));
224 await act(async () => pool.primeFileHighlightCache(files[1]!));
225 expect(testState.pools.size).toBe(1);
226 expect(testState.workers).toHaveLength(2);
227 expect(new Set(testState.renderPools)).toEqual(new Set([pool]));
228 expect(pool.getFileResultCache(files[1]!)).toBeDefined();
229 await vi.waitFor(() => expect(codeFile("answer.ts")).toContain("answer"));
230​
231 await view.render(renderViews(1));
232 expect(pool.getStats().totalWorkers).toBe(2);
233 expect(testState.terminations).toBe(0);
234 await view.render(renderViews(0));
235 await vi.advanceTimersByTimeAsync(29_999);
236 expect(pool.getStats().totalWorkers).toBe(2);
237 expect(testState.terminations).toBe(0);
238​
239 await view.render(renderViews(1));
240 expect(testState.pools.size).toBe(1);
241 expect(testState.workers).toHaveLength(2);
242 expect(loadingViews()).toBe(0);
243 expect(pool.getFileResultCache(files[1]!)).toBeDefined();
244 await vi.advanceTimersByTimeAsync(30_000);
245 expect(pool.getStats().totalWorkers).toBe(2);
246​
247 await view.render(renderViews(0));
248 await vi.advanceTimersByTimeAsync(30_000);
249 expect(pool.getStats().totalWorkers).toBe(0);
250 expect(testState.terminations).toBe(2);
251​
252 await view.render(renderViews(1));
253 const reopenedPool = [...testState.pools.keys()][1]!;
254 await act(async () => testState.pools.get(reopenedPool));
255 expect(reopenedPool.isInitialized()).toBe(true);
256 expect(testState.workers).toHaveLength(4);
257 expect(document.querySelector("button")).toBe(button);
258 expect(button.textContent).toBe("Edited draft");
259 await vi.waitFor(() => expect(codeFile("notes.txt")).toContain("Plain text is ready."));
260 });
261​
262 it("renders through Pierre's main-thread fallback when worker creation fails", async () => {
263 testState.failWorkers = true;
264 await mount(renderViews(1)).initial;
265 const pool = [...testState.pools.keys()][0]!;
266 await act(async () => {
267 await expect(testState.pools.get(pool)).rejects.toMatchObject({ _tag: "DiffWorkerError" });
268 await getSharedHighlighter({
269 themes: ["pierre-dark"],
270 langs: ["text"],
271 preferredHighlighter: "shiki-wasm",
272 });
273 });
274 expect(pool.isWorkingPool()).toBe(false);
275 expect(testState.workers).toHaveLength(0);
276 await vi.waitFor(() => expect(codeFile("notes.txt")).toContain("Plain text is ready."));
277 });
278​
279 it("keeps an initializing pool until its last view closes and ignores late responses", async () => {
280 testState.holdInitialization = true;
281 const held = new Promise<void>((resolve) => {
282 testState.onInitializationHeld = resolve;
283 });
284 const view = mount(renderViews(2));
285 await view.initial;
286 const pool = [...testState.pools.keys()][0]!;
287 const pending = testState.pools.get(pool)!;
288 await held;
289 expect(pool.isInitialized()).toBe(false);
290 expect(testState.pools.size).toBe(1);
291 expect(loadingViews()).toBe(2);
292 expect(testState.renderPools).toHaveLength(0);
293​
294 await view.render(renderViews(1));
295 expect(pool.getStats().totalWorkers).toBe(2);
296 expect(testState.terminations).toBe(0);
297 await view.render(renderViews(0));
298 // Pierre gives up on a held startup after 10 seconds; the idle timer then tears the pool down.
299 const timedOut = expect(pending).rejects.toThrow("worker initialization timed out");
300 await vi.advanceTimersByTimeAsync(30_000);
301 await timedOut;
302 await act(async () => {
303 for (const deliver of testState.heldResponses) deliver();
304 });
305 expect(pool.getStats().totalWorkers).toBe(0);
306 expect(testState.workers).toHaveLength(2);
307 expect(testState.terminations).toBe(2);
308 expect(testState.renderPools).toHaveLength(0);
309 expect(document.querySelectorAll("pre")).toHaveLength(0);
310 });
311});
312​
313describe("collapsed diff content", () => {
314 let pool: WorkerPoolManager;
315 let container: HTMLDivElement;
316 let viewer: FileDiff<string> | CodeView<string> | undefined;
317​
318 const loadedDiff = () => {
319 const parsed = getRenderablePatch(
320 [
321 "diff --git a/before.ts b/after.ts",
322 "similarity index 50%",
323 "rename from before.ts",
324 "rename to after.ts",
325 "--- a/before.ts",
326 "+++ b/after.ts",
327 "@@ -1,2 +1,2 @@",
328 " const shared = 1;",
329 "-const before = 2;",
330 "+const after = 3;",
331 ].join("\n"),
332 "collapsed-content",
333 );
334 if (parsed?.kind !== "files" || !parsed.files[0]) throw new Error("Expected diff");
335 return parsed.files[0];
336 };
337 const code = () =>
338 [...container.querySelectorAll("diffs-container")]
339 .flatMap((element) => [...(element.shadowRoot?.querySelectorAll("[data-line]") ?? [])])
340 .map((line) => line.textContent)
341 .join("\n");
342​
343 beforeEach(async () => {
344 testState.requests = [];
345 testState.failWorkers = false;
346 testState.holdInitialization = false;
347 pool = new WorkerPoolManager(
348 { workerFactory: () => new DiffsWorker(), poolSize: 1 },
349 { theme: "pierre-dark", langs: ["typescript"], preferredHighlighter: "shiki-wasm" },
350 );
351 await pool.initialize();
352 container = document.createElement("div");
353 container.style.cssText = "height: 400px; width: 800px; overflow: auto";
354 document.body.append(container);
355 });
356​
357 afterEach(() => {
358 viewer?.cleanUp();
359 viewer = undefined;
360 pool.terminate();
361 container.remove();
362 vi.restoreAllMocks();
363 });
364​
365 it("defers plain AST and highlight work across collapsed renders until expansion", async () => {
366 const fileDiff = loadedDiff();
367 const highlight = vi.spyOn(pool, "highlightDiffAST");
368 const plainAST = vi.spyOn(pool, "getPlainDiffAST");
369 const options = { theme: "pierre-dark", collapsed: true, disableErrorHandling: true } as const;
370 const file = new FileDiff<string>(options, pool);
371 viewer = file;
372 file.render({ fileDiff, containerWrapper: container });
373 file.render({ fileDiff, forceRender: true });
374 expect.soft(highlight.mock.calls.length).toBe(0);
375 expect.soft(plainAST.mock.calls.length).toBe(0);
376 expect(code()).toBe("");
377 expect(container.querySelector("diffs-container")?.shadowRoot?.textContent).toContain(
378 "after.ts",
379 );
380​
381 file.setOptions({ ...options, collapsed: false });
382 file.render({ fileDiff, forceRender: true });
383 expect(highlight).toHaveBeenCalled();
384 await pool.primeDiffHighlightCache(fileDiff);
385 await vi.waitFor(() => expect(code()).toContain("const after = 3;"));
386 expect(code()).toContain("const before = 2;");
387 expect(testState.requests.filter((request) => request.type === "diff")).toHaveLength(1);
388 });
389​
390 it("finds newly loaded collapsed lines and unfolds the match with its annotation and header", async () => {
391 const fileDiff = loadedDiff();
392 const item: CodeViewItem<string> = {
393 type: "diff",
394 id: "renamed",
395 fileDiff,
396 collapsed: true,
397 annotations: [{ side: "additions", lineNumber: 2, metadata: "Review this change" }],
398 };
399 const view = new CodeView<string>(
400 {
401 theme: "pierre-dark",
402 disableErrorHandling: true,
403 onRevealSearchMatch: (match) =>
404 view.setItems([{ ...match, collapsed: false, version: (match.version ?? 0) + 1 }]),
405 renderHeaderMetadata: (file) => {
406 if (!("hunks" in file)) return;
407 const metadata = document.createElement("span");
408 const { additions, deletions } = getDiffLineStat([file]);
409 metadata.textContent = "+" + additions + " / -" + deletions;
410 return metadata;
411 },
412 renderAnnotation: (annotation) => {
413 const note = document.createElement("span");
414 note.textContent = annotation.metadata ?? "";
415 return note;
416 },
417 },
418 pool,
419 );
420 viewer = view;
421 view.setup(container);
422 view.openSearch();
423 const search = container.querySelector("[data-diffs-search]")!.shadowRoot!;
424 const input = search.querySelector<HTMLInputElement>("input[data-search]")!;
425 input.value = "const after";
426 input.dispatchEvent(new Event("input", { bubbles: true }));
427 view.setItems([item]);
428 view.render(true);
429 expect(code()).toBe("");
430 expect(search.textContent).toContain("1 results");
431 expect(container.textContent).toContain("+1 / -1");
432​
433 input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
434 view.render(true);
435 await vi.waitFor(() => expect(code()).toContain("const after = 3;"));
436 expect(search.textContent).toContain("1 of 1");
437 expect(container.textContent).toContain("Review this change");
438 expect(container.textContent).toContain("+1 / -1");
439 expect(container.querySelector("diffs-container")?.shadowRoot?.textContent).toContain(
440 "after.ts",
441 );
442​
443 await pool.primeDiffHighlightCache(fileDiff);
444 view.render(true);
445 const highlight = vi.spyOn(pool, "highlightDiffAST");
446 const plainAST = vi.spyOn(pool, "getPlainDiffAST");
447 const updatedDiff = { ...fileDiff, name: "updated.ts", cacheKey: "collapsed-update" };
448 view.setItems([{ ...item, fileDiff: updatedDiff, version: 2 }]);
449 view.render(true);
450 expect(highlight).not.toHaveBeenCalled();
451 expect(plainAST).not.toHaveBeenCalled();
452 expect(code()).toBe("");
453 expect(search.textContent).toContain("1 of 1");
454 expect(container.querySelector("diffs-container")?.shadowRoot?.textContent).toContain(
455 "updated.ts",
456 );
457 input.dispatchEvent(new KeyboardEvent("keydown", { key: "Enter", bubbles: true }));
458 view.render(true);
459 await vi.waitFor(() => expect(code()).toContain("const after = 3;"));
460 expect(container.textContent).toContain("Review this change");
461 });
462});
463​
464type RevealHandle = NonNullable<Parameters<typeof useCodeViewFileReveal>[0]>;
465const revealCalls: {
466 scope: string;
467 fileKey: string;
468 mounted: boolean;
469 collapsed: boolean | undefined;
470}[] = [];
471​
472function RevealViewer({
473 viewerRef,
474 scope,
475 collapsed,
476}: {
477 viewerRef: Ref<RevealHandle>;
478 scope: string;
479 collapsed: boolean;
480}) {
481 const instance = useRef<{ collapsed: boolean } | undefined>(undefined);
482 useLayoutEffect(() => {
483 instance.current = { collapsed };
484 return () => {
485 instance.current = undefined;
486 };
487 }, [collapsed]);
488 useImperativeHandle(
489 viewerRef,
490 () => ({
491 getInstance: () => instance.current,
492 scrollTo: (target: CodeViewScrollTarget) => {
493 if (target.type !== "item") return;
494 revealCalls.push({
495 scope,
496 fileKey: target.id,
497 mounted: instance.current !== undefined,
498 collapsed: instance.current?.collapsed,
499 });
500 },
501 }),
502 [scope],
503 );
504 return null;
506​
507function RevealViews({
508 scope,
509 visible,
510 selectedFile = null,
511 requestId = 0,
512}: {
513 scope: string;
514 visible: boolean;
515 selectedFile?: string | null;
516 requestId?: number;
517}) {
518 const [viewer, setViewer] = useState<RevealHandle | null>(null);
519 const [collapsed, setCollapsed] = useState(true);
520 // The reveal hook cancels pending clicks by scope identity, so a scope object
521 // must only be replaced when one of its inputs changes.
522 const [storedRevealScope, setRevealScope] = useState(() => ({
523 scope,
524 selectedRequest: { selectedFile, requestId },
525 }));
526 let revealScope = storedRevealScope;
527 if (
528 revealScope.scope !== scope ||
529 revealScope.selectedRequest.selectedFile !== selectedFile ||
530 revealScope.selectedRequest.requestId !== requestId
531 ) {
532 revealScope = {
533 scope,
534 selectedRequest:
535 revealScope.selectedRequest.selectedFile === selectedFile &&
536 revealScope.selectedRequest.requestId === requestId
537 ? revealScope.selectedRequest
538 : { selectedFile, requestId },
539 };
540 setRevealScope(revealScope);
541 }
542 const { selectedRequest } = revealScope;
543 useEffect(() => {
544 if (!selectedRequest.selectedFile || !viewer?.getInstance()) return;
545 viewer.scrollTo({ type: "item", id: selectedRequest.selectedFile, align: "start" });
546 }, [selectedRequest, viewer]);
547 const requestReveal = useCodeViewFileReveal(viewer, revealScope);
548 return (
549 <>
550 {visible && (
551 <RevealViewer key={scope} viewerRef={setViewer} scope={scope} collapsed={collapsed} />
552 )}
553 <button
554 onClick={() => {
555 setCollapsed(false);
556 requestReveal("tree-file");
557 }}
558 >
559 Reveal file
560 </button>
561 </>
562 );
564​
565describe("code-view file reveals", () => {
566 let view: ReturnType<typeof mount>;
567 const reveal = () => act(async () => document.querySelector("button")!.click());
568​
569 beforeEach(() => {
570 revealCalls.length = 0;
571 vi.stubGlobal("IS_REACT_ACT_ENVIRONMENT", true);
572 });
573​
574 afterEach(async () => {
575 await unmountAll();
576 vi.unstubAllGlobals();
577 });
578​
579 it("does not replay a handled tree click or scroll an old handle when a selected file remounts the view", async () => {
580 view = mount(<RevealViews scope="first" visible selectedFile="external-a" />);
581 await view.initial;
582 await reveal();
583 expect(revealCalls.at(-1)?.fileKey).toBe("tree-file");
584 revealCalls.length = 0;
585​
586 await view.render(
587 <RevealViews scope="second" visible selectedFile="external-b" requestId={1} />,
588 );
589 expect(revealCalls).toEqual([
590 { scope: "second", fileKey: "external-b", mounted: true, collapsed: false },
591 ]);
592 });
593​
594 it("waits for a live viewer and applies each pending tree click only once", async () => {
595 view = mount(<RevealViews scope="diff" visible={false} selectedFile="external" />);
596 await view.initial;
597 await reveal();
598 expect(revealCalls).toEqual([]);
599​
600 await view.render(<RevealViews scope="diff" visible selectedFile="external" />);
601 expect(revealCalls.map((call) => call.fileKey)).toEqual(["external", "tree-file"]);
602 revealCalls.length = 0;
603 await view.render(<RevealViews scope="diff" visible={false} selectedFile="external" />);
604 await view.render(<RevealViews scope="diff" visible selectedFile="external" />);
605 expect(revealCalls).toEqual([
606 { scope: "diff", fileKey: "external", mounted: true, collapsed: false },
607 ]);
608​
609 revealCalls.length = 0;
610 // A click that lands in the same update that hides the viewer waits for it to return.
611 await act(async () => {
612 document.querySelector("button")!.click();
613 view.root.render(<RevealViews scope="diff" visible={false} selectedFile="external" />);
614 });
615 expect(revealCalls).toEqual([]);
616 await view.render(<RevealViews scope="diff" visible selectedFile="external" />);
617 expect(revealCalls).toEqual([
618 { scope: "diff", fileKey: "external", mounted: true, collapsed: false },
619 { scope: "diff", fileKey: "tree-file", mounted: true, collapsed: false },
620 ]);
621 });
622​
623 it("cancels pending tree clicks when an external selection or diff scope changes", async () => {
624 view = mount(<RevealViews scope="first" visible={false} selectedFile="external-a" />);
625 await view.initial;
626 await reveal();
627 await view.render(
628 <RevealViews scope="first" visible selectedFile="external-b" requestId={1} />,
629 );
630 expect(revealCalls.map((call) => call.fileKey)).toEqual(["external-b"]);
631 revealCalls.length = 0;
632​
633 await view.render(<RevealViews scope="first" visible={false} />);
634 await reveal();
635 await view.render(<RevealViews scope="second" visible={false} />);
636 await view.render(<RevealViews scope="first" visible />);
637 expect(revealCalls).toEqual([]);
638 });
639​
640 it("reveals after a collapsed file expands and honors another click on the same file", async () => {
641 view = mount(<RevealViews scope="diff" visible />);
642 await view.initial;
643 await reveal();
644 await reveal();
645 expect(revealCalls).toEqual([
646 { scope: "diff", fileKey: "tree-file", mounted: true, collapsed: false },
647 { scope: "diff", fileKey: "tree-file", mounted: true, collapsed: false },
648 ]);
649 });
650});