mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-03 12:49:30 +00:00
f9343e5458
* Fix desktop registering protocol handler wrong Was previously registering with too many args and was also only handling deeplinks if the app was already open, on a cold start they would be blindly ignored. Tests aplenty * Refactor Desktop config to avoid global and centralise defaults * Improve coverage * Fix tests * Improve coverage * Fix test * Rename field * Improve coverage * Rename field * Move protocolHandler initialisation to after mainWindow is navigating * Add comment * Avoid double call to loadURL * Improve coverage * Improve coverage * Fix tsc
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
/*
|
|
Copyright 2026 Element Creations Ltd.
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
|
|
Please see LICENSE files in the repository root for full details.
|
|
*/
|
|
|
|
import { expect, describe, it, beforeEach, vi } from "vitest";
|
|
import { Tray } from "electron";
|
|
|
|
import { getConfig } from "./config.js";
|
|
|
|
vi.mock("electron", () => ({
|
|
Tray: vi.fn(
|
|
class {
|
|
public setToolTip = vi.fn();
|
|
public setContextMenu = vi.fn();
|
|
public on = vi.fn();
|
|
},
|
|
),
|
|
Menu: {
|
|
buildFromTemplate: vi.fn(),
|
|
},
|
|
nativeImage: {
|
|
createFromPath: vi.fn(),
|
|
},
|
|
app: {
|
|
isPackaged: true,
|
|
},
|
|
}));
|
|
|
|
vi.mock("./icon.js");
|
|
vi.mock("./config.js");
|
|
|
|
describe("create", () => {
|
|
let create: () => Promise<void>;
|
|
|
|
beforeEach(async () => {
|
|
// The tray is disabled on macOS so test under win32
|
|
vi.spyOn(process, "platform", "get").mockReturnValue("win32");
|
|
({ create } = await import("./tray.js"));
|
|
});
|
|
|
|
it("should use config.brand", async () => {
|
|
vi.mocked(getConfig).mockReturnValue({ brand: "ChatApp", help_url: "HELP_URL", web_base_url: "WEB_BASE_URL" });
|
|
await create();
|
|
const tray = vi.mocked(Tray).mock.instances[0];
|
|
expect(tray.setToolTip).toHaveBeenCalledWith("ChatApp");
|
|
});
|
|
});
|