Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

1.7 KB
Raw Blame
import { Bot } from "@langfuse/icons";
import { expect, fn, userEvent, within } from "storybook/test";

import preview from "../../../../.storybook/preview";
import { Callout } from "./Callout";

const meta = preview.meta({
  component: Callout,
});

const message = (
  <div className="flex items-start gap-2 sm:items-center">
    <Bot size="base" __rawClassName="mt-0.5 sm:mt-0" />
    <span>
      <span className="font-bold">
        Langfuse works great with your AI agents.
      </span>{" "}
      Connect your tools to your Langfuse data.
    </span>
  </div>
);

export const Default = meta.story({
  args: {
    variant: "info",
    align: "middle",
    children: message,
    actions: [],
    onDismiss: fn(),
  },
});

export const Warning = meta.story({
  args: {
    variant: "warning",
    align: "top",
    children: (
      <span>
        <span className="font-bold">Heads up:</span> this workspace is close to
        its ingestion limit.
      </span>
    ),
    actions: [],
    onDismiss: fn(),
  },
});

export const WithActions = meta.story({
  args: {
    variant: "info",
    align: "middle",
    children: message,
    actions: [
      { type: "button", label: "Learn more", onClick: fn() },
      { type: "button", label: "Not now", onClick: fn() },
    ],
    onDismiss: fn(),
  },
});

export const Dismisses = meta.story({
  name: "(Test) Dismisses",
  args: {
    variant: "info",
    align: "middle",
    children: <span>This callout can be dismissed.</span>,
    actions: [],
    onDismiss: fn(),
  },
  play: async ({ args, canvasElement }) => {
    const canvas = within(canvasElement);

    await userEvent.click(
      await canvas.findByRole("button", { name: "Dismiss" }),
    );

    await expect(args.onDismiss).toHaveBeenCalledOnce();
  },
});