IKHSAN
EN Read in EnglishID

homeio

Publik

Fork dari doctor-io/homeio

Branch
main
Commit terakhir
958d74616 Oktober 2026

app-settings-panel.test.tsx

Buka raw
/* @vitest-environment jsdom */

import { render } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";

const appConfiguratorPanelMock = vi.fn((props: unknown) => props);

vi.mock("@/modules/apps/components/configurator/app-configurator-panel", () => ({
  AppConfiguratorPanel: (props: unknown) => {
    appConfiguratorPanelMock(props);
    return null;
  },
}));

import { AppSettingsPanel } from "@/modules/apps/components/configurator/app-settings-panel";

describe("AppSettingsPanel wrapper", () => {
  it("maps target usage to installed_edit context", () => {
    render(
      <AppSettingsPanel
        target={{
          appId: "plex",
          appName: "Plex",
          containerName: "plex",
          dashboardUrl: "http://localhost:32400",
        }}
      />, 
    );

    expect(appConfiguratorPanelMock).toHaveBeenCalledWith(
      expect.objectContaining({
        context: "installed_edit",
      }),
    );
  });

  it("maps template usage to catalog_install context", () => {
    render(
      <AppSettingsPanel
        template={{
          id: "home-assistant",
          name: "Home Assistant",
          description: "Home automation",
          platform: "linux",
          categories: ["Automation"],
          logoUrl: null,
          repositoryUrl: "https://github.com/home-assistant/core",
          stackFile: "compose.yml",
          status: "not_installed",
          webUiPort: 8123,
          updateAvailable: false,
          localDigest: null,
          remoteDigest: null,
          note: "",
          env: [],
          screenshots: [],
          installedConfig: null,
        }}
      />,
    );

    expect(appConfiguratorPanelMock).toHaveBeenCalledWith(
      expect.objectContaining({
        context: "catalog_install",
      }),
    );
  });

  it("defaults to custom_install context when no target/template", () => {
    render(<AppSettingsPanel />);

    expect(appConfiguratorPanelMock).toHaveBeenCalledWith(
      expect.objectContaining({
        context: "custom_install",
      }),
    );
  });
});
byte
2.083
baris
79
Jenis
tsx
Commit terakhir
16 Oktober 2026