mirror of
https://github.com/webadderallorg/Recordly.git
synced 2026-09-28 16:55:36 +00:00
* Fix cursor sync after recording pause * Align recorder and cursor pause boundaries
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
vi.mock("electron", () => ({
|
|
app: {
|
|
getPath: vi.fn(() => "/tmp"),
|
|
},
|
|
}));
|
|
|
|
vi.mock("../utils", () => ({
|
|
getTelemetryPathForVideo: vi.fn(() => "/tmp/recording.cursor.json"),
|
|
getScreen: vi.fn(() => ({
|
|
getCursorScreenPoint: () => ({ x: 0, y: 0 }),
|
|
getPrimaryDisplay: () => ({ scaleFactor: 1 }),
|
|
getDisplayNearestPoint: () => ({ bounds: { x: 0, y: 0, width: 1, height: 1 } }),
|
|
getAllDisplays: () => [],
|
|
})),
|
|
}));
|
|
|
|
import {
|
|
getCursorCaptureElapsedMs,
|
|
pauseCursorCapture,
|
|
resetCursorCaptureClock,
|
|
resumeCursorCapture,
|
|
} from "./telemetry";
|
|
import { setCursorCaptureStartTimeMs } from "../state";
|
|
|
|
describe("cursor telemetry pause clock", () => {
|
|
beforeEach(() => {
|
|
setCursorCaptureStartTimeMs(1_000);
|
|
resetCursorCaptureClock();
|
|
});
|
|
|
|
it("subtracts paused time from elapsed cursor timestamps", () => {
|
|
expect(getCursorCaptureElapsedMs(1_120)).toBe(120);
|
|
|
|
pauseCursorCapture(1_200);
|
|
expect(getCursorCaptureElapsedMs(1_450)).toBe(200);
|
|
|
|
resumeCursorCapture(1_700);
|
|
expect(getCursorCaptureElapsedMs(1_900)).toBe(400);
|
|
});
|
|
|
|
it("ignores duplicate pause or resume transitions", () => {
|
|
pauseCursorCapture(1_150);
|
|
pauseCursorCapture(1_250);
|
|
resumeCursorCapture(1_500);
|
|
resumeCursorCapture(1_650);
|
|
|
|
expect(getCursorCaptureElapsedMs(1_900)).toBe(550);
|
|
});
|
|
});
|