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

Quelle  channel-validation.test.ts

  Sprache: JAVA
 

Spracherkennung für: .ts vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

import { describe, expect, it } from "vitest";
import { getChatChannelMeta } from "../channels/chat-meta.js";
import type { ChannelPlugin } from "../channels/plugins/types.public.js";
import { normalizeRegisteredChannelPlugin } from "./channel-validation.js";
import type { PluginDiagnostic } from "./types.js";

function collectDiagnostics() {
  const diagnostics: PluginDiagnostic[] = [];
  return {
    diagnostics,
    pushDiagnostic: (diag: PluginDiagnostic) => {
      diagnostics.push(diag);
    },
  };
}

function createChannelPlugin(overrides?: Partial<ChannelPlugin>): ChannelPlugin {
  return {
    id: "demo",
    meta: {
      id: "demo",
      label: "Demo",
      selectionLabel: "Demo",
      docsPath: "/channels/demo",
      blurb: "demo channel",
    },
    capabilities: { chatTypes: ["direct"] },
    config: {
      listAccountIds: () => [],
      resolveAccount: () => ({ accountId: "default" }),
    },
    ...overrides,
  };
}

describe("normalizeRegisteredChannelPlugin", () => {
  it("fills bundled channel metadata from the canonical core baseline", () => {
    const { diagnostics, pushDiagnostic } = collectDiagnostics();

    const normalized = normalizeRegisteredChannelPlugin({
      pluginId: "demo-plugin",
      source: "/tmp/demo/index.ts",
      plugin: createChannelPlugin({
        id: "telegram",
        meta: {
          id: "telegram",
        } as never,
      }),
      pushDiagnostic,
    });

    const telegram = getChatChannelMeta("telegram");
    expect(normalized?.meta).toMatchObject({
      label: telegram.label,
      selectionLabel: telegram.selectionLabel,
      docsPath: telegram.docsPath,
      blurb: telegram.blurb,
    });
    expect(diagnostics.map((diag) => diag.message)).toEqual([
      'channel "telegram" registered incomplete metadata; filled missing label, selectionLabel, docsPath, blurb',
    ]);
  });

  it("falls back to the channel id for external channels with incomplete metadata", () => {
    const { diagnostics, pushDiagnostic } = collectDiagnostics();

    const normalized = normalizeRegisteredChannelPlugin({
      pluginId: "demo-plugin",
      source: "/tmp/demo/index.ts",
      plugin: createChannelPlugin({
        id: "external-chat",
        meta: {
          id: "external-chat",
        } as never,
      }),
      pushDiagnostic,
    });

    expect(normalized?.id).toBe("external-chat");
    expect(normalized?.meta).toMatchObject({
      id: "external-chat",
      label: "external-chat",
      selectionLabel: "external-chat",
      docsPath: "/channels/external-chat",
      blurb: "",
    });
    expect(diagnostics.map((diag) => diag.message)).toEqual([
      'channel "external-chat" registered incomplete metadata; filled missing label, selectionLabel, docsPath, blurb',
    ]);
  });

  it("warns and repairs mismatched meta ids", () => {
    const { diagnostics, pushDiagnostic } = collectDiagnostics();

    const normalized = normalizeRegisteredChannelPlugin({
      pluginId: "demo-plugin",
      source: "/tmp/demo/index.ts",
      plugin: createChannelPlugin({
        id: "demo",
        meta: {
          id: "other-demo",
          label: "Demo",
          selectionLabel: "Demo",
          docsPath: "/channels/demo",
          blurb: "demo channel",
        },
      }),
      pushDiagnostic,
    });

    expect(normalized?.id).toBe("demo");
    expect(normalized?.meta.id).toBe("demo");
    expect(diagnostics.map((diag) => diag.message)).toEqual([
      'channel "demo" meta.id mismatch ("other-demo"); using registered channel id',
    ]);
  });
});

¤ Dauer der Verarbeitung: 0.0 Sekunden  (vorverarbeitet am  2026-04-27) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

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.