- Move the read-only OpenAPI compat surface from /api/v2/assets to /mjr/am/compat/assets so it never squats ComfyUI core's /api namespace; the legacy alias is opt-in via MJR_AM_LEGACY_API_V2_ASSETS=1. - Allow Python 3.14 (requires-python <3.15) and add 3.14 to CI and tox. - Stop wrapping api.queuePrompt: progress tracking now resolves the running prompt from the core Jobs API (getJobDetail), then /queue and /history, driven by websocket events. Remove wrapHostQueuePrompt. - Add opt-in Majoor.Integration.HideNativeAssetsTab setting that hides ComfyUI's native Assets sidebar tab through the official getSidebarTabs/unregisterSidebarTab API and restores it when disabled. - Fix all 913 type errors in tsconfig.test.json and type-check tests in CI; drop a duplicated `stubs` key in asset_card_inner test; make addToastHistory's type argument optional for the object form. - Update audit report, changelog, API reference and env var docs.
90 lines
2.9 KiB
TypeScript
90 lines
2.9 KiB
TypeScript
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
|
|
const getExtensionDialogApi = vi.fn(() => null);
|
|
const getExtensionToastApi = vi.fn(() => null);
|
|
const getComfyApp = vi.fn(() => null);
|
|
|
|
vi.mock("../app/comfyApiBridge.js", () => ({
|
|
getComfyApp,
|
|
getExtensionDialogApi,
|
|
getExtensionToastApi,
|
|
}));
|
|
|
|
vi.mock("../app/i18n.js", () => ({
|
|
t: (_key, fallback) => fallback,
|
|
}));
|
|
|
|
beforeEach(() => {
|
|
vi.resetModules();
|
|
vi.clearAllMocks();
|
|
getExtensionDialogApi.mockReturnValue(null);
|
|
getExtensionToastApi.mockReturnValue(null);
|
|
getComfyApp.mockReturnValue(null);
|
|
globalThis.window = {
|
|
confirm: vi.fn(() => true),
|
|
prompt: vi.fn(() => "fallback"),
|
|
alert: vi.fn(),
|
|
} as any;
|
|
globalThis.document = {
|
|
createElement: vi.fn(() => ({
|
|
style: {},
|
|
appendChild: vi.fn(),
|
|
setAttribute: vi.fn(),
|
|
})) as any,
|
|
} as any;
|
|
});
|
|
|
|
describe("dialogs", () => {
|
|
it("uses extension dialog confirm/prompt first", async () => {
|
|
getExtensionDialogApi.mockReturnValue({
|
|
confirm: vi.fn(async () => true),
|
|
prompt: vi.fn(async () => "native-value"),
|
|
});
|
|
|
|
const mod = await import("../app/dialogs.js");
|
|
await expect(mod.comfyConfirm("Delete?")).resolves.toBe(true);
|
|
await expect(mod.comfyPrompt("Name", "x")).resolves.toBe("native-value");
|
|
expect(window.confirm).not.toHaveBeenCalled();
|
|
expect(window.prompt).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("uses extension dialog alert before toast and browser alert", async () => {
|
|
const alert = vi.fn(async () => undefined);
|
|
const addAlert = vi.fn();
|
|
getExtensionDialogApi.mockReturnValue({ alert });
|
|
getExtensionToastApi.mockReturnValue({
|
|
add: vi.fn(),
|
|
addAlert,
|
|
});
|
|
|
|
const mod = await import("../app/dialogs.js");
|
|
await mod.comfyAlert("Indexed", "Majoor");
|
|
|
|
expect(alert).toHaveBeenCalledWith({ title: "Majoor", message: "Indexed" });
|
|
expect(addAlert).not.toHaveBeenCalled();
|
|
expect(window.alert).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("uses extension toast alert before browser alert", async () => {
|
|
const addAlert = vi.fn();
|
|
getExtensionToastApi.mockReturnValue({
|
|
add: vi.fn(),
|
|
addAlert,
|
|
});
|
|
|
|
const mod = await import("../app/dialogs.js");
|
|
await mod.comfyAlert("Indexed");
|
|
|
|
expect(addAlert).toHaveBeenCalledWith("Indexed");
|
|
expect(window.alert).not.toHaveBeenCalled();
|
|
});
|
|
|
|
it("falls back to window dialogs when no native surface exists", async () => {
|
|
const mod = await import("../app/dialogs.js");
|
|
await expect(mod.comfyConfirm("Delete?")).resolves.toBe(true);
|
|
await expect(mod.comfyPrompt("Name", "x")).resolves.toBe("fallback");
|
|
expect(window.confirm).toHaveBeenCalled();
|
|
expect(window.prompt).toHaveBeenCalled();
|
|
});
|
|
});
|