Skip to content

Commit 07f5f3f

Browse files
committed
Fix tests
1 parent 03e4fe9 commit 07f5f3f

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

webview-ui/src/components/modes/__tests__/ModesView.spec.tsx

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ describe("PromptsView", () => {
162162
expect(screen.queryByTestId("role-definition-reset")).not.toBeInTheDocument()
163163
})
164164

165-
it("resets description only for built-in modes", async () => {
165+
it("description section behavior for different mode types", async () => {
166166
const customMode = {
167167
slug: "custom-mode",
168168
name: "Custom Mode",
@@ -171,42 +171,35 @@ describe("PromptsView", () => {
171171
groups: [],
172172
}
173173

174-
// Test with built-in mode (code)
174+
// Test with built-in mode (code) - description section should not be shown
175175
const { unmount } = render(
176176
<ExtensionStateContext.Provider
177177
value={{ ...mockExtensionState, mode: "code", customModes: [customMode] } as any}>
178178
<ModesView onDone={vitest.fn()} />
179179
</ExtensionStateContext.Provider>,
180180
)
181181

182-
// Find and click the description reset button
183-
const resetButton = screen.getByTestId("description-reset")
184-
expect(resetButton).toBeInTheDocument()
185-
await fireEvent.click(resetButton)
186-
187-
// Verify it only resets description
188-
// When resetting a built-in mode's description, the field should be removed entirely
189-
// from the customPrompt object, not set to undefined.
190-
// This allows the default description from the built-in mode to be used instead.
191-
expect(vscode.postMessage).toHaveBeenCalledWith({
192-
type: "updatePrompt",
193-
promptMode: "code",
194-
customPrompt: {}, // Empty object because the description field is removed entirely
195-
})
182+
// Verify description reset button is not present for built-in modes
183+
// because the description section is only shown for custom modes
184+
expect(screen.queryByTestId("description-reset")).not.toBeInTheDocument()
196185

197186
// Cleanup before testing custom mode
198187
unmount()
199188

200-
// Test with custom mode
189+
// Test with custom mode - description section should be shown
201190
render(
202191
<ExtensionStateContext.Provider
203192
value={{ ...mockExtensionState, mode: "custom-mode", customModes: [customMode] } as any}>
204193
<ModesView onDone={vitest.fn()} />
205194
</ExtensionStateContext.Provider>,
206195
)
207196

208-
// Verify reset button is not present for custom mode
197+
// Verify description section is present for custom modes
198+
// but reset button is not present (since it's only for built-in modes)
209199
expect(screen.queryByTestId("description-reset")).not.toBeInTheDocument()
200+
201+
// Verify the description text field is present for custom modes
202+
expect(screen.getByTestId("custom-mode-description-textfield")).toBeInTheDocument()
210203
})
211204

212205
it("handles clearing custom instructions correctly", async () => {

0 commit comments

Comments
 (0)