Files
yaak-mountain-loop/apps/yaak-proxy/lib/opener.test.ts
T
Gregory SchierandClaude Opus 5.5 c78732ecaf Polish Yaak Proxy's flow list, sidebar and header
Columns keep fixed widths, Path included, and the list scrolls sideways
with the header in step instead of dropping columns or capping Host.
Resize handles sit on every column boundary, a double-click resets one,
and a third click on a sorted header goes back to start time, with empty
values sorting lowest. The search box takes up to 44rem and wraps over
the list while focused, its completions as wide as it. The list/detail
handle fills the gutter. Native title tooltips become Yaak's tooltip,
shared buttons gain an opt-in for it, and folder and program rows in the
sidebar get Reveal in Finder and Copy path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 10:45:46 -07:00

49 lines
1.7 KiB
TypeScript

import { beforeEach, describe, expect, test, vi } from "vite-plus/test";
const opener = vi.hoisted(() => ({
openUrl: vi.fn<(url: string) => Promise<void>>(),
revealItemInDir: vi.fn<(path: string) => Promise<void>>(),
}));
vi.mock("@tauri-apps/plugin-opener", () => opener);
const { openLink, revealLabel, revealPath } = await import("./opener");
describe("opener", () => {
beforeEach(() => {
opener.openUrl.mockReset();
opener.revealItemInDir.mockReset();
});
test("a folder that can't be shown says so", async () => {
opener.revealItemInDir.mockRejectedValue("not allowed: opener.reveal_item_in_dir");
const report = vi.fn();
await revealPath("/data/app.yaak.proxy", report);
expect(opener.revealItemInDir).toHaveBeenCalledWith("/data/app.yaak.proxy");
expect(report).toHaveBeenCalledWith(
"Failed to show /data/app.yaak.proxy: not allowed: opener.reveal_item_in_dir",
);
});
test("nothing to report when it works", async () => {
opener.revealItemInDir.mockResolvedValue();
opener.openUrl.mockResolvedValue();
const report = vi.fn();
await revealPath("/logs", report);
await openLink("https://yaak.app", report);
expect(report).not.toHaveBeenCalled();
});
test("a link that can't be opened says so", async () => {
opener.openUrl.mockRejectedValue(new Error("denied"));
const report = vi.fn();
await openLink("https://yaak.app", report);
expect(report).toHaveBeenCalledWith("Failed to open https://yaak.app: Error: denied");
});
test("names the file manager by platform", () => {
expect(revealLabel("macos")).toBe("Reveal in Finder");
expect(revealLabel("windows")).toBe("Show in Explorer");
expect(revealLabel("linux")).toBe("Show in Folder");
});
});