diff --git a/webui2/src/components/shared/query-input.stories.tsx b/webui2/src/components/shared/query-input.stories.tsx
index 2b4c35982c04972d41307abbda3761e30db9d531..a77f1e088a4b21aff2c47c294de44749f7956a24 100644
--- a/webui2/src/components/shared/query-input.stories.tsx
+++ b/webui2/src/components/shared/query-input.stories.tsx
@@ -1,5 +1,6 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
import { Search } from "lucide-react";
+import { expect, userEvent, within } from "storybook/test";
import { useState } from "react";
import type { CompletionProvider } from "./query-input";
@@ -148,3 +149,38 @@ export const AsyncCompletions: Story = {
);
},
};
+
+export const AutocompleteInteraction: Story = {
+ args: { children: null, value: "", onChange: () => {}, onSubmit: () => {} },
+ render: () => {
+ const [value, setValue] = useState("");
+ return (
+
{}}
+ providers={providers}
+ >
+
+
+
+
+ );
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+ const input = canvas.getByRole("textbox");
+
+ // Type "label:" to trigger suggestions
+ await userEvent.type(input, "label:");
+ // Suggestions dropdown should appear
+ const bugOption = await canvas.findByText("bug");
+ await expect(bugOption).toBeVisible();
+
+ // First suggestion is already highlighted — press Enter to select
+ await userEvent.keyboard("{Enter}");
+
+ // Input should now contain the selected label
+ await expect(input).toHaveValue("label:bug ");
+ },
+};
diff --git a/webui2/src/components/shared/write-preview.stories.tsx b/webui2/src/components/shared/write-preview.stories.tsx
index 1460eed919e5f1499743079f5659849a6a9f18e2..0013cd48833e04e732d6a87f7367da73c19376f2 100644
--- a/webui2/src/components/shared/write-preview.stories.tsx
+++ b/webui2/src/components/shared/write-preview.stories.tsx
@@ -1,4 +1,5 @@
import type { Meta, StoryObj } from "@storybook/react-vite";
+import { expect, userEvent, within } from "storybook/test";
import { useState } from "react";
import { Markdown } from "@/components/content/markdown";
@@ -80,3 +81,50 @@ export const Empty: Story = {
),
};
+
+export const TabSwitching: Story = {
+ args: { children: null },
+ render: () => {
+ const [message, setMessage] = useState("Some **content** to preview.");
+ return (
+
+
+
+
+
+
+
+
+
+
+ );
+ },
+ play: async ({ canvasElement }) => {
+ const canvas = within(canvasElement);
+
+ // Initially on Write tab — textarea visible
+ const textarea = canvas.getByRole("textbox");
+ await expect(textarea).toBeVisible();
+
+ // Click Preview tab
+ const previewBtn = canvas.getByRole("button", { name: "Preview" });
+ await userEvent.click(previewBtn);
+
+ // Textarea should be gone, preview content visible
+ await expect(canvas.queryByRole("textbox")).toBeNull();
+ await expect(canvas.getByText("content")).toBeVisible();
+
+ // Click Write tab to switch back
+ const writeBtn = canvas.getByRole("button", { name: "Write" });
+ await userEvent.click(writeBtn);
+
+ // Textarea visible again
+ await expect(canvas.getByRole("textbox")).toBeVisible();
+ },
+};