Skip to content

Commit 3b726a2

Browse files
committed
fix: update test to handle new checkRulesDirectory behavior
The ModesView component now checks for rules directory on mount, which was causing the test to fail. Updated the test to clear mock calls after mount and properly simulate the focus/change/blur sequence for field editing.
1 parent 42ff981 commit 3b726a2

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,15 @@ describe("PromptsView", () => {
9595
it("handles prompt changes correctly", async () => {
9696
renderPromptsView()
9797

98+
// Clear any messages that were sent during component mount (like checkRulesDirectory)
99+
vitest.clearAllMocks()
100+
98101
// Get the textarea
99102
const textarea = await waitFor(() => screen.getByTestId("code-prompt-textarea"))
100103

104+
// First focus the textarea to trigger the editing state
105+
fireEvent.focus(textarea)
106+
101107
// Simulate VSCode TextArea change event
102108
const changeEvent = new CustomEvent("change", {
103109
detail: {
@@ -109,6 +115,9 @@ describe("PromptsView", () => {
109115

110116
fireEvent(textarea, changeEvent)
111117

118+
// Now blur to trigger the save
119+
fireEvent.blur(textarea)
120+
112121
expect(vscode.postMessage).toHaveBeenCalledWith({
113122
type: "updatePrompt",
114123
promptMode: "code",

0 commit comments

Comments
 (0)