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.
This commit is contained in:
Roo Code 2025-07-18 13:49:36 +00:00
parent 42ff98163d
commit 3b726a284b

View file

@ -95,9 +95,15 @@ describe("PromptsView", () => {
it("handles prompt changes correctly", async () => {
renderPromptsView()
// Clear any messages that were sent during component mount (like checkRulesDirectory)
vitest.clearAllMocks()
// Get the textarea
const textarea = await waitFor(() => screen.getByTestId("code-prompt-textarea"))
// First focus the textarea to trigger the editing state
fireEvent.focus(textarea)
// Simulate VSCode TextArea change event
const changeEvent = new CustomEvent("change", {
detail: {
@ -109,6 +115,9 @@ describe("PromptsView", () => {
fireEvent(textarea, changeEvent)
// Now blur to trigger the save
fireEvent.blur(textarea)
expect(vscode.postMessage).toHaveBeenCalledWith({
type: "updatePrompt",
promptMode: "code",