Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 


Quelle  channels-misc.test.ts

  Sprache: JAVA
 

import { afterEach, describe, expect, it, vi } from "vitest";
import { normalizeChatType } from "./chat-type.js";

const readLazyString = (value: unknown): string => String(value);

describe("normalizeChatType", () => {
  it.each([
    { name: "normalizes direct", value: "direct", expected: "direct" },
    { name: "normalizes dm alias", value: "dm", expected: "direct" },
    { name: "normalizes group", value: "group", expected: "group" },
    { name: "normalizes channel", value: "channel", expected: "channel" },
    { name: "returns undefined for undefined", value: undefined, expected: undefined },
    { name: "returns undefined for empty", value: "", expected: undefined },
    { name: "returns undefined for unknown value", value: "nope", expected: undefined },
    { name: "returns undefined for unsupported room", value: "room", expected: undefined },
  ] satisfies Array<{ name: string; value: string | undefined; expected: string | undefined }>)(
    "$name",
    ({ value, expected }) => {
      expect(normalizeChatType(value)).toBe(expected);
    },
  );

  describe("backward compatibility", () => {
    it("accepts legacy 'dm' value shape variants and normalizes to 'direct'", () => {
      // Legacy config/input may use "dm" with non-canonical casing/spacing.
      expect(normalizeChatType("DM")).toBe("direct");
      expect(normalizeChatType(" dm ")).toBe("direct");
    });
  });
});

describe("WA_WEB_AUTH_DIR", () => {
  afterEach(() => {
    vi.doUnmock("../plugins/runtime/runtime-web-channel-plugin.js");
  });

  it("resolves lazily and caches across the legacy and channels/web entrypoints", async () => {
    const resolveWebChannelAuthDir = vi.fn(() => "/tmp/openclaw-whatsapp-auth");

    vi.resetModules();
    vi.doMock("../plugins/runtime/runtime-web-channel-plugin.js", () => ({
      createWebChannelSocket: vi.fn(),
      extractMediaPlaceholder: vi.fn(),
      extractText: vi.fn(),
      formatError: vi.fn(),
      getStatusCode: vi.fn(),
      logWebSelfId: vi.fn(),
      loginWeb: vi.fn(),
      logoutWeb: vi.fn(),
      monitorWebChannel: vi.fn(),
      monitorWebInbox: vi.fn(),
      pickWebChannel: vi.fn(),
      resolveHeartbeatRecipients: vi.fn(),
      resolveWebChannelAuthDir,
      runWebHeartbeatOnce: vi.fn(),
      sendWebChannelMessage: vi.fn(),
      sendWebChannelReaction: vi.fn(),
      waitForWebChannelConnection: vi.fn(),
      webAuthExists: vi.fn(),
    }));

    const channelWeb = await import("../channel-web.js");
    const webEntry = await import("./web/index.js");

    expect(resolveWebChannelAuthDir).not.toHaveBeenCalled();
    expect(readLazyString(channelWeb.WA_WEB_AUTH_DIR)).toBe("/tmp/openclaw-whatsapp-auth");
    expect(readLazyString(webEntry.WA_WEB_AUTH_DIR)).toBe("/tmp/openclaw-whatsapp-auth");
    expect(resolveWebChannelAuthDir).toHaveBeenCalledTimes(1);
  });
});

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

¤ Dauer der Verarbeitung: 0.14 Sekunden  (vorverarbeitet am  2026-05-26) ¤

*© 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.






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge