diff --git a/webui2/src/components/shared/__snapshots__/query-input.test.tsx.snap b/webui2/src/components/shared/__snapshots__/query-input.test.tsx.snap index 3421de7555fdcaa2957bec4b94d00cc4d2ebb148..40e79a2fe898bb923cbc04ac67434ee629633679 100644 --- a/webui2/src/components/shared/__snapshots__/query-input.test.tsx.snap +++ b/webui2/src/components/shared/__snapshots__/query-input.test.tsx.snap @@ -47,6 +47,67 @@ exports[`QueryInput/AsyncCompletions matches snapshot 1`] = ` `; +exports[`QueryInput/AutocompleteInteraction matches snapshot 1`] = ` +
+
+
+ +
+ + +
+
+`; + exports[`QueryInput/Default matches snapshot 1`] = `
`; +exports[`WritePreview/TabSwitching matches snapshot 1`] = ` +
+
+
+ + +
+ +
+
+`; + exports[`WritePreview/Uncontrolled matches snapshot 1`] = `
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 ( + + + +