mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 23:44:41 +00:00
* fix(desktop): restore macOS app updates Electron 41's Squirrel helper can leave the update handoff dormant on current macOS, so Paseo quits cleanly but relaunches the old bundle. Electron 44 wakes ShipIt through its XPC service. Include updater lifecycle events and ShipIt state in app diagnostics so future handoff failures identify the current version, target version, cache paths, and installer output. * fix(desktop): harden updater diagnostics Keep each ShipIt file's evidence available when another read fails, carry the service-selected version into updater lifecycle logs, and make clean workspace installs resolve the Electron runtime used by desktop tests. * refactor(desktop): name updater install options * refactor(desktop): name updater log payloads * refactor(desktop): name clipboard payload * fix(desktop): surface updater lookup failures * test(desktop): await guest focus transition * fix(desktop): guard macOS update compatibility * test(release): validate desktop manifests before publish * test(desktop): await populated daemon pid file
72 lines
2.3 KiB
TypeScript
72 lines
2.3 KiB
TypeScript
import { describe, expect, it, vi } from "vitest";
|
|
import {
|
|
createBrowserCaptureService,
|
|
type BrowserCaptureGuest,
|
|
type BrowserCaptureImage,
|
|
} from "./browser-capture.js";
|
|
|
|
function image(dataUrl = "data:image/png;base64,capture"): BrowserCaptureImage {
|
|
return { isEmpty: () => false, toDataURL: () => dataUrl };
|
|
}
|
|
|
|
function harness(guest: BrowserCaptureGuest | null = null) {
|
|
const clipboard = { write: vi.fn(async () => undefined) };
|
|
const decodeImage = vi.fn(() => image("data:image/png;base64,clipboard"));
|
|
const warn = vi.fn();
|
|
return {
|
|
clipboard,
|
|
decodeImage,
|
|
warn,
|
|
service: createBrowserCaptureService({
|
|
findGuest: () => guest,
|
|
decodeImage,
|
|
clipboard,
|
|
warn,
|
|
}),
|
|
};
|
|
}
|
|
|
|
describe("browser capture service", () => {
|
|
it("validates and rounds guest-relative bounds before capture", async () => {
|
|
const capturePage = vi.fn(async () => image());
|
|
const { service } = harness({ isDestroyed: () => false, capturePage });
|
|
|
|
await expect(
|
|
service.capture({
|
|
browserId: "browser-1",
|
|
hostWebContentsId: 42,
|
|
rect: { x: -2.4, y: 8.6, width: 20.2, height: 10.8 },
|
|
}),
|
|
).resolves.toBe("data:image/png;base64,capture");
|
|
expect(capturePage).toHaveBeenCalledWith({ x: 0, y: 9, width: 20, height: 11 });
|
|
});
|
|
|
|
it("rejects invalid or unavailable captures without touching the guest", async () => {
|
|
const capturePage = vi.fn(async () => image());
|
|
const { service } = harness({ isDestroyed: () => false, capturePage });
|
|
|
|
await expect(
|
|
service.capture({ browserId: "browser-1", hostWebContentsId: 42, rect: { width: 0 } }),
|
|
).resolves.toBeNull();
|
|
expect(capturePage).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("writes text and a decoded image to the clipboard atomically", async () => {
|
|
const { service, clipboard } = harness();
|
|
await expect(
|
|
service.copy({ text: "button", imageDataUrl: "data:image/png;base64,value" }),
|
|
).resolves.toBe(true);
|
|
expect(clipboard.write).toHaveBeenCalledWith({
|
|
text: "button",
|
|
image: expect.any(Object),
|
|
});
|
|
});
|
|
|
|
it("keeps text-only clipboard writes", async () => {
|
|
const { service, clipboard } = harness();
|
|
|
|
await expect(service.copy({ text: "button" })).resolves.toBe(true);
|
|
expect(clipboard.write).toHaveBeenCalledWith({ text: "button", image: null });
|
|
});
|
|
});
|