Skip to content

Commit e226fee

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 e226fee

File tree

2 files changed

+67
-1
lines changed

2 files changed

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

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)