Files
MajoorWaldi-ComfyUI-Majoor-…/ui/tests/viewer_open_request.vitest.ts
T
Ewald ALOEBOETOE ee5bc6ead5 Remove the classic viewer and its player; keep only the Studio viewer
The Studio viewer now covers everything the classic overlay did, so the
classic runtime (toolbar, panzoom, A/B and side-by-side engine, scopes,
loupe, probe, grading and WebGL video processors, filmstrip, context menu,
keyboard handling), its styles and its tests are deleted.

- Every open request goes to the Studio viewer; requestViewerOpen no longer
  falls back to a viewer singleton.
- Drop the classic-only settings (use classic viewer, pan without zoom,
  disable WebGL) and their internal options and constants.
- Studio tells the grid which asset it ended on when it closes, and the
  rating hotkeys yield to it while it is open.
- Remove dead helpers left behind (image processor, media player helpers,
  3D helpers, metadata block, viewerbar controls variant) and unused CSS.
- Update the viewer tutorial, hotkeys doc and changelog.
2026-11-04 13:04:25 +00:00

45 lines
1.6 KiB
TypeScript

// @vitest-environment happy-dom
import { describe, expect, it, vi } from "vitest";
import { EVENTS } from "../app/events.js";
import { requestViewerOpen } from "../features/viewer/viewerOpenRequest.js";
describe("requestViewerOpen", () => {
const asset = { id: 1, filename: "one.png", kind: "image" };
it("reports false when no viewer handles the request", () => {
expect(requestViewerOpen({ assets: [asset], index: 0 })).toBe(false);
});
it("reports false without assets", () => {
expect(requestViewerOpen({ assets: [] })).toBe(false);
});
it("dispatches OPEN_VIEWER and returns true once a listener handles it", () => {
const onOpen = vi.fn((event: Event) => {
(event as CustomEvent).detail.handled = true;
});
window.addEventListener(EVENTS.OPEN_VIEWER, onOpen);
try {
expect(requestViewerOpen({ asset, index: 5, mode: " AB " })).toBe(true);
const detail = (onOpen.mock.calls[0][0] as CustomEvent).detail;
expect(detail.assets).toEqual([asset]);
expect(detail.index).toBe(0);
expect(detail.mode).toBe("ab");
} finally {
window.removeEventListener(EVENTS.OPEN_VIEWER, onOpen);
}
});
it("drops unknown modes", () => {
const onOpen = vi.fn();
window.addEventListener(EVENTS.OPEN_VIEWER, onOpen);
try {
requestViewerOpen({ assets: [asset], mode: "bogus" });
expect((onOpen.mock.calls[0][0] as CustomEvent).detail.mode).toBe("");
} finally {
window.removeEventListener(EVENTS.OPEN_VIEWER, onOpen);
}
});
});