mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-11-12 00:42:53 +00:00
Test auto-zoom click filtering for recording overlays
This commit is contained in:
1 parent
2eee9afd9b
commit
908bb938fb
1 file changed
+60
-2
@@ -12,14 +12,72 @@ vi.mock("electron", () => ({
|
||||
}));
|
||||
|
||||
vi.mock("../../windows", () => ({
|
||||
getHudOverlayInteractiveBounds: vi.fn(() => null),
|
||||
getHudOverlayWindow: vi.fn(() => null),
|
||||
getHudOverlayInteractiveBounds: vi.fn(),
|
||||
getHudOverlayWindow: vi.fn(() => ({
|
||||
isVisible: () => true,
|
||||
isMinimized: () => false,
|
||||
})),
|
||||
}));
|
||||
|
||||
vi.mock("../utils", () => ({
|
||||
getScreen: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("./telemetry", () => ({
|
||||
getCursorCaptureElapsedMs: () => 42,
|
||||
getNormalizedCursorPoint: () => ({ cx: 0.2, cy: 0.3 }),
|
||||
isCursorCapturePaused: () => false,
|
||||
pushCursorSample: vi.fn(),
|
||||
}));
|
||||
|
||||
import { getHudOverlayInteractiveBounds } from "../../windows";
|
||||
import { setIsCursorCaptureActive, setLastLeftClick } from "../state";
|
||||
import { getScreen } from "../utils";
|
||||
import {
|
||||
recordCursorMouseDown,
|
||||
repairBundledUiohookBinaryForCurrentArch,
|
||||
shouldStartGlobalInteractionHook,
|
||||
} from "./interaction";
|
||||
import { pushCursorSample } from "./telemetry";
|
||||
|
||||
describe("recordCursorMouseDown with recording overlays", () => {
|
||||
afterEach(() => {
|
||||
setIsCursorCaptureActive(false);
|
||||
setLastLeftClick(null);
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it("skips clicks on the HUD and webcam preview and records clicks outside both", () => {
|
||||
setIsCursorCaptureActive(true);
|
||||
setLastLeftClick(null);
|
||||
vi.mocked(getHudOverlayInteractiveBounds).mockReturnValue([
|
||||
{ left: 100, top: 100, right: 400, bottom: 150 },
|
||||
{ left: 450, top: 200, right: 550, bottom: 300 },
|
||||
]);
|
||||
const getCursorScreenPoint = vi
|
||||
.fn()
|
||||
.mockReturnValueOnce({ x: 200, y: 125 })
|
||||
.mockReturnValueOnce({ x: 500, y: 250 })
|
||||
.mockReturnValueOnce({ x: 425, y: 180 });
|
||||
vi.mocked(getScreen).mockReturnValue({ getCursorScreenPoint } as ReturnType<
|
||||
typeof getScreen
|
||||
>);
|
||||
|
||||
recordCursorMouseDown(1);
|
||||
recordCursorMouseDown(1);
|
||||
expect(pushCursorSample).not.toHaveBeenCalled();
|
||||
|
||||
recordCursorMouseDown(1);
|
||||
expect(pushCursorSample).toHaveBeenCalledExactlyOnceWith(
|
||||
0.2,
|
||||
0.3,
|
||||
42,
|
||||
"click",
|
||||
undefined,
|
||||
1,
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("shouldStartGlobalInteractionHook", () => {
|
||||
it("does not start the synchronous uiohook event tap on macOS", () => {
|
||||
|
||||
Reference in new issue
Block a user