* perf(app): bound large diff row mounting Keep the existing vertical and horizontal scroll owners so virtualization does not change gesture or scrolling behavior. Reserve exact offscreen row heights while mounting only the visible window, and retain the full renderer when wrapping or editing reviews requires dynamic geometry. * perf(app): keep large diff reviews responsive Opening an inline editor changed the whole review action object, reconciled large syntax-token trees, and disabled row virtualization. Keep the expensive token subtree stable and preserve deterministic row geometry while the editor is open.\n\nBound server-side highlighting for pathological single lines and remove the unused client highlighter so the actual diff pipeline owns the limit. * test(app): check mounted diff typography Row virtualization can unmount a fixed diff row after scrolling. Assert the configured font size against a currently mounted row so the test continues to verify rendered typography without depending on window position. * test(app): stabilize Mermaid streaming coverage
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import {
|
|
compactHighlightTokens,
|
|
formatDiffContentText,
|
|
formatDiffGutterText,
|
|
hasVisibleDiffTokens,
|
|
} from "./diff-rendering";
|
|
|
|
describe("diff-rendering", () => {
|
|
it("keeps header gutters tall even when they do not show a line number", () => {
|
|
// Must be a non-collapsing whitespace: the gutter <Text> uses
|
|
// numberOfLines={1}, which on web wraps in display:-webkit-box;
|
|
// overflow:hidden. A plain ASCII space collapses to zero height
|
|
// there and shifts every line number up by one row.
|
|
expect(formatDiffGutterText(null)).toBe("\u00A0");
|
|
expect(formatDiffGutterText(82)).toBe("82");
|
|
});
|
|
|
|
it("keeps empty split cells tall even when they have no visible content", () => {
|
|
expect(formatDiffContentText(undefined)).toBe(" ");
|
|
expect(formatDiffContentText("")).toBe(" ");
|
|
expect(formatDiffContentText("const value = 1;")).toBe("const value = 1;");
|
|
});
|
|
|
|
it("treats empty highlighted token rows as blank lines instead of visible content", () => {
|
|
expect(hasVisibleDiffTokens(undefined)).toBe(false);
|
|
expect(hasVisibleDiffTokens([])).toBe(false);
|
|
expect(hasVisibleDiffTokens([{ text: "" }])).toBe(false);
|
|
expect(hasVisibleDiffTokens([{ text: "const value = 1;" }])).toBe(true);
|
|
});
|
|
|
|
it("compacts adjacent syntax tokens without changing their text or styles", () => {
|
|
expect(
|
|
compactHighlightTokens([
|
|
{ text: "const", style: "keyword" },
|
|
{ text: " ", style: null },
|
|
{ text: "value", style: null },
|
|
{ text: " ", style: null },
|
|
{ text: "=", style: "operator" },
|
|
{ text: "", style: "operator" },
|
|
{ text: " 1", style: "number" },
|
|
]),
|
|
).toEqual([
|
|
{ text: "const", style: "keyword" },
|
|
{ text: " value ", style: null },
|
|
{ text: "=", style: "operator" },
|
|
{ text: " 1", style: "number" },
|
|
]);
|
|
});
|
|
});
|