Skip to content

Commit 0296454

Browse files
fix(tests): add htmlFor/id to model select so getByLabelText resolves correctly
1 parent e34d93e commit 0296454

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

__tests__/components/PromptForm.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ describe("PromptForm - rendering", () => {
6767

6868
it("renders the model select with default value gpt-4o", () => {
6969
renderWithAuth();
70-
const select = screen.getByRole("combobox", { name: /model/i }) as HTMLSelectElement;
70+
const select = screen.getByLabelText(/model/i) as HTMLSelectElement;
7171
expect(select.value).toBe("gpt-4o");
7272
});
7373
});

components/PromptForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ export function PromptForm({ onDirtyChange }: PromptFormProps) {
223223
)}
224224
</div>
225225
<div>
226-
<label className="block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-1.5">
226+
<label htmlFor="model-select" className="block text-sm font-medium text-neutral-700 dark:text-neutral-300 mb-1.5">
227227
Model
228228
</label>
229229
<select
230+
id="model-select"
230231
value={model}
231232
onChange={(e) => { setModel(e.target.value as PromptModel); markDirty(); }}
232233
className="w-full px-4 py-2.5 bg-white dark:bg-neutral-900 border border-neutral-200 dark:border-neutral-800 rounded-lg text-neutral-900 dark:text-neutral-100 focus:outline-none focus:ring-2 focus:ring-neutral-300 dark:focus:ring-neutral-700 transition-shadow"

0 commit comments

Comments
 (0)