Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  approval-native-delivery.test.ts

  Sprache: JAVA
 

import { describe, expect, it } from "vitest";
import type { ChannelApprovalNativeAdapter } from "../channels/plugins/types.adapters.js";
import { resolveChannelNativeApprovalDeliveryPlan } from "./approval-native-delivery.js";

const execRequest = {
  id: "approval-1",
  request: {
    command: "uname -a",
  },
  createdAtMs: 0,
  expiresAtMs: 120_000,
};

describe("resolveChannelNativeApprovalDeliveryPlan", () => {
  it("prefers the origin surface when configured and available", async () => {
    const adapter: ChannelApprovalNativeAdapter = {
      describeDeliveryCapabilities: () => ({
        enabled: true,
        preferredSurface: "origin",
        supportsOriginSurface: true,
        supportsApproverDmSurface: true,
      }),
      resolveOriginTarget: async () => ({ to: "origin-chat", threadId: "42" }),
      resolveApproverDmTargets: async () => [{ to: "approver-1" }],
    };

    const plan = await resolveChannelNativeApprovalDeliveryPlan({
      cfg: {} as never,
      approvalKind: "exec",
      request: execRequest,
      adapter,
    });

    expect(plan.notifyOriginWhenDmOnly).toBe(false);
    expect(plan.targets).toEqual([
      {
        surface: "origin",
        target: { to: "origin-chat", threadId: "42" },
        reason: "preferred",
      },
    ]);
  });

  it("falls back to approver DMs when origin delivery is unavailable", async () => {
    const adapter: ChannelApprovalNativeAdapter = {
      describeDeliveryCapabilities: () => ({
        enabled: true,
        preferredSurface: "origin",
        supportsOriginSurface: true,
        supportsApproverDmSurface: true,
      }),
      resolveOriginTarget: async () => null,
      resolveApproverDmTargets: async () => [{ to: "approver-1" }, { to: "approver-2" }],
    };

    const plan = await resolveChannelNativeApprovalDeliveryPlan({
      cfg: {} as never,
      approvalKind: "exec",
      request: execRequest,
      adapter,
    });

    expect(plan.targets).toEqual([
      {
        surface: "approver-dm",
        target: { to: "approver-1" },
        reason: "fallback",
      },
      {
        surface: "approver-dm",
        target: { to: "approver-2" },
        reason: "fallback",
      },
    ]);
  });

  it("requests an origin redirect notice when DM-only delivery has an origin context", async () => {
    const adapter: ChannelApprovalNativeAdapter = {
      describeDeliveryCapabilities: () => ({
        enabled: true,
        preferredSurface: "approver-dm",
        supportsOriginSurface: true,
        supportsApproverDmSurface: true,
        notifyOriginWhenDmOnly: true,
      }),
      resolveOriginTarget: async () => ({ to: "origin-chat" }),
      resolveApproverDmTargets: async () => [{ to: "approver-1" }],
    };

    const plan = await resolveChannelNativeApprovalDeliveryPlan({
      cfg: {} as never,
      approvalKind: "plugin",
      request: {
        ...execRequest,
        id: "plugin:approval-1",
        request: {
          title: "Plugin approval",
          description: "Needs access",
        },
      },
      adapter,
    });

    expect(plan.originTarget).toEqual({ to: "origin-chat" });
    expect(plan.notifyOriginWhenDmOnly).toBe(true);
    expect(plan.targets).toEqual([
      {
        surface: "approver-dm",
        target: { to: "approver-1" },
        reason: "preferred",
      },
    ]);
  });

  it("dedupes duplicate origin and DM targets when both surfaces converge", async () => {
    const adapter: ChannelApprovalNativeAdapter = {
      describeDeliveryCapabilities: () => ({
        enabled: true,
        preferredSurface: "both",
        supportsOriginSurface: true,
        supportsApproverDmSurface: true,
      }),
      resolveOriginTarget: async () => ({ to: "shared-chat" }),
      resolveApproverDmTargets: async () => [{ to: "shared-chat" }, { to: "approver-2" }],
    };

    const plan = await resolveChannelNativeApprovalDeliveryPlan({
      cfg: {} as never,
      approvalKind: "exec",
      request: execRequest,
      adapter,
    });

    expect(plan.targets).toEqual([
      {
        surface: "origin",
        target: { to: "shared-chat" },
        reason: "preferred",
      },
      {
        surface: "approver-dm",
        target: { to: "approver-2" },
        reason: "preferred",
      },
    ]);
  });
});

Messung V0.5 in Prozent
C=93 H=90 G=91

¤ Dauer der Verarbeitung: 0.9 Sekunden  (vorverarbeitet am  2026-06-05) ¤

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik