Files
paseo/packages/app/src/git/file-header-interaction.test.ts
T
Mohamed Boudra 3998ea11d9 Keep large diffs responsive across web and mobile (#4174)
* perf(app): keep large diffs responsive

Render file headers on the canvas and bound expensive text shaping to the active viewport while preserving sticky, hover, and horizontal-scroll behavior. Let native scroll cancellation arbitrate header presses so finger scrolling cannot expand files.

* test(app): assert canvas diff header accessibility

* test(app): assert canvas diff header semantics
2026-09-01 23:52:11 +02:00

34 lines
1.0 KiB
TypeScript

import { describe, expect, it } from "vitest";
import {
reduceFileHeaderPress,
type FileHeaderPressEvent,
type FileHeaderPressPhase,
} from "./file-header-interaction";
describe("file header interaction arbitration", () => {
function run(events: FileHeaderPressEvent[]) {
let phase: FileHeaderPressPhase = "idle";
const effects: string[] = [];
for (const event of events) {
const next = reduceFileHeaderPress(phase, event);
phase = next.phase;
if (next.effect !== "none") effects.push(next.effect);
}
return effects;
}
it("activates an actual press", () => {
expect(run([{ type: "press-in" }, { type: "press" }])).toEqual(["activate"]);
});
it("does not activate when scrolling cancels the press", () => {
expect(run([{ type: "press-in" }])).toEqual([]);
});
it("selects a long press without activating when Pressability later emits press", () => {
expect(run([{ type: "press-in" }, { type: "long-press" }, { type: "press" }])).toEqual([
"select",
]);
});
});