Skip to content

Commit ad9a600

Browse files
committed
test: add ChatInput story to guard model favorites integration
Adds a story that clicks the model selector and verifies star icons appear in the dropdown. This will fail if the defaultModel/onSetDefaultModel props are not passed from ChatInput to ModelSelector.
1 parent 90bc192 commit ad9a600

File tree

2 files changed

+70
-1
lines changed

2 files changed

+70
-1
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import type { Meta, StoryObj } from "@storybook/react-vite";
2+
import { userEvent, within, expect } from "storybook/test";
3+
import React from "react";
4+
import { ChatInput } from "./index";
5+
import { ModeProvider } from "@/browser/contexts/ModeContext";
6+
import { ThinkingProvider } from "@/browser/contexts/ThinkingContext";
7+
8+
const meta: Meta = {
9+
title: "Components/ChatInput",
10+
parameters: {
11+
layout: "padded",
12+
},
13+
decorators: [
14+
(Story) => (
15+
<ModeProvider>
16+
<ThinkingProvider workspaceId="storybook-test">
17+
<div className="w-[600px]">
18+
<Story />
19+
</div>
20+
</ThinkingProvider>
21+
</ModeProvider>
22+
),
23+
],
24+
};
25+
26+
export default meta;
27+
type Story = StoryObj;
28+
29+
// eslint-disable-next-line @typescript-eslint/no-empty-function
30+
const noop = async () => {};
31+
32+
export const WorkspaceVariant: Story = {
33+
render: () => (
34+
<ChatInput variant="workspace" workspaceId="test-workspace-id" onTruncateHistory={noop} />
35+
),
36+
};
37+
38+
/**
39+
* This story verifies the model favorites integration is working.
40+
*
41+
* When clicking the model selector, the dropdown should show star icons
42+
* next to each model for setting/viewing the default model. If the stars
43+
* are missing, the favorites integration has been broken.
44+
*/
45+
export const ModelFavoritesIntegration: Story = {
46+
render: () => (
47+
<ChatInput
48+
variant="workspace"
49+
workspaceId="test-workspace-favorites"
50+
onTruncateHistory={noop}
51+
/>
52+
),
53+
play: async ({ canvasElement }) => {
54+
const canvas = within(canvasElement);
55+
56+
// Click the model selector to open dropdown
57+
const modelSelector = canvas.getByRole("button", { name: /claude|anthropic|model/i });
58+
await userEvent.click(modelSelector);
59+
60+
// The dropdown should show star icons for setting default model
61+
// Look for the star buttons in the dropdown
62+
const starButtons = canvasElement.querySelectorAll(
63+
'[data-component="ModelSelectorGroup"] button svg'
64+
);
65+
66+
// There should be star icons visible (at least one for each model in dropdown)
67+
// This will fail if defaultModel/onSetDefaultModel props are not passed
68+
await expect(starButtons.length).toBeGreaterThan(0);
69+
},
70+
};

src/browser/components/ChatInput/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@ export const ChatInput: React.FC<ChatInputProps> = (props) => {
178178
[storageKeys.modelKey, addModel]
179179
);
180180

181-
182181
// When entering creation mode (or when the default model changes), reset the
183182
// project-scoped model to the explicit default so manual picks don't bleed
184183
// into subsequent creation flows.

0 commit comments

Comments
 (0)