Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/JAVA/Openclaw/src/   (Openclaw AI Version 22©)  Datei vom 26.3.2026 mit Größe 3 kB image not shown  

Quelle  ui-app-settings.agents-files-refresh.test.ts

  Sprache: JAVA
 

import { beforeEach, describe, expect, it, vi } from "vitest";

const loadAgentsMock = vi.hoisted(() =>
  vi.fn(async (host: { agentsList?: unknown }) => {
    host.agentsList = {
      defaultId: "main",
      mainKey: "main",
      scope: "per-sender",
      agents: [{ id: "main" }],
    };
  }),
);
const loadConfigMock = vi.hoisted(() => vi.fn(async () => undefined));
const loadAgentIdentitiesMock = vi.hoisted(() => vi.fn(async () => undefined));
const loadAgentIdentityMock = vi.hoisted(() => vi.fn(async () => undefined));
const loadAgentSkillsMock = vi.hoisted(() => vi.fn(async () => undefined));
const loadAgentFilesMock = vi.hoisted(() => vi.fn(async () => undefined));
const loadChannelsMock = vi.hoisted(() => vi.fn(async () => undefined));

vi.mock("../ui/src/ui/controllers/agents.ts", () => ({
  loadAgents: loadAgentsMock,
}));

vi.mock("../ui/src/ui/controllers/config.ts", () => ({
  loadConfig: loadConfigMock,
  loadConfigSchema: vi.fn(async () => undefined),
}));

vi.mock("../ui/src/ui/controllers/agent-identity.ts", () => ({
  loadAgentIdentities: loadAgentIdentitiesMock,
  loadAgentIdentity: loadAgentIdentityMock,
}));

vi.mock("../ui/src/ui/controllers/agent-skills.ts", () => ({
  loadAgentSkills: loadAgentSkillsMock,
}));

vi.mock("../ui/src/ui/controllers/agent-files.ts", () => ({
  loadAgentFiles: loadAgentFilesMock,
}));

vi.mock("../ui/src/ui/controllers/channels.ts", () => ({
  loadChannels: loadChannelsMock,
}));

vi.mock("../ui/src/ui/controllers/cron.ts", () => ({
  loadCronJobsPage: vi.fn(async () => undefined),
  loadCronRuns: vi.fn(async () => undefined),
  loadCronStatus: vi.fn(async () => undefined),
}));

import { refreshActiveTab } from "../ui/src/ui/app-settings.ts";

type AgentsPanel = "overview" | "files" | "tools" | "skills" | "channels" | "cron";

function createHost(agentsPanel: AgentsPanel): Parameters<typeof refreshActiveTab>[0] {
  return {
    tab: "agents",
    connected: true,
    agentsPanel,
    agentsList: null,
    agentsSelectedId: null,
    settings: {
      gatewayUrl: "",
      token: "",
      sessionKey: "main",
      lastActiveSessionKey: "main",
      theme: "claw",
      themeMode: "system",
      chatFocusMode: false,
      chatShowThinking: true,
      chatShowToolCalls: true,
      splitRatio: 0.6,
      navCollapsed: false,
      navWidth: 220,
      navGroupsCollapsed: {},
      borderRadius: 50,
    },
    theme: "claw",
    themeMode: "system",
    themeResolved: "dark",
    applySessionKey: "main",
    sessionKey: "main",
    chatHasAutoScrolled: false,
    logsAtBottom: false,
    eventLog: [],
    eventLogBuffer: [],
    basePath: "",
    dreamingStatusLoading: false,
    dreamingStatusError: null,
    dreamingStatus: null,
    dreamingModeSaving: false,
    dreamDiaryLoading: false,
    dreamDiaryError: null,
    dreamDiaryPath: null,
    dreamDiaryContent: null,
  } as Parameters<typeof refreshActiveTab>[0];
}

describe("refreshActiveTab (agents/files)", () => {
  beforeEach(() => {
    loadAgentsMock.mockClear();
    loadConfigMock.mockClear();
    loadAgentIdentitiesMock.mockClear();
    loadAgentIdentityMock.mockClear();
    loadAgentSkillsMock.mockClear();
    loadAgentFilesMock.mockClear();
    loadChannelsMock.mockClear();
  });

  it("loads agent files when the active agents panel is files", async () => {
    const host = createHost("files");
    await refreshActiveTab(host);

    expect(loadAgentFilesMock).toHaveBeenCalledTimes(1);
    expect(loadAgentFilesMock).toHaveBeenCalledWith(host, "main");
  });

  it("does not load agent files on non-files panels", async () => {
    const host = createHost("overview");
    await refreshActiveTab(host);

    expect(loadAgentFilesMock).not.toHaveBeenCalled();
  });
});

Messung V0.5 in Prozent
C=100 H=100 G=100

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.