Skip to content

Commit 9799cbb

Browse files
committed
test(webview): assert the normalized textarea value for malformed inputs
Address the CodeRabbit nitpick on the Zoo-Code-Org#1226 regression tests: assert the rendered textarea value is empty for both the undefined and non-string inputValue cases, covering the normalizedInputValue binding before the Enhance prompt interaction.
1 parent d9daf14 commit 9799cbb

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

‎webview-ui/src/components/chat/__tests__/ChatTextArea.spec.tsx‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,6 +1223,11 @@ describe("ChatTextArea", () => {
12231223
// "Cannot read properties of undefined (reading 'trim')" in the
12241224
// hasInputContent memo. It should render normally instead.
12251225

1226+
// The normalized value drives the textarea: a malformed input renders as empty.
1227+
const textarea = container.querySelector("textarea")
1228+
expect(textarea).toBeInTheDocument()
1229+
expect(textarea).toHaveValue("")
1230+
12261231
// Clicking "Enhance prompt" with an undefined input must not crash either:
12271232
// the undefined input behaves like an empty one, so nothing is sent.
12281233
mockPostMessage.mockClear()
@@ -1242,6 +1247,11 @@ describe("ChatTextArea", () => {
12421247
const badInput = { ...defaultProps, inputValue: value } as unknown as typeof defaultProps
12431248
const { container } = render(<ChatTextArea {...badInput} />)
12441249

1250+
// The normalized value drives the textarea: a non-string input renders as empty.
1251+
const textarea = container.querySelector("textarea")
1252+
expect(textarea).toBeInTheDocument()
1253+
expect(textarea).toHaveValue("")
1254+
12451255
mockPostMessage.mockClear()
12461256
fireEvent.click(getEnhancePromptButton())
12471257
expect(mockPostMessage).not.toHaveBeenCalledWith(expect.objectContaining({ type: "enhancePrompt" }))

0 commit comments

Comments
 (0)