mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-14 23:21:19 +00:00
test: align terminal tests with shell integration safeguards
Update TerminalProcessExec tests to properly handle shell integration
event sequences:
- Set terminal.running=true before command execution
- Remove duplicate command execution that could trigger extra events
- Replace arbitrary timeout with event-based waiting for output
- Ensure proper event sequence (run -> start -> output -> end)
This aligns the tests with the safeguards added in 62ffa797 that
prevent spurious shell integration events from corrupting terminal
state.
Signed-off-by: Eric Wheeler <roo-code@z.ewheeler.org>
This commit is contained in:
parent
62ffa7973c
commit
701b5a7d87
1 changed files with 10 additions and 7 deletions
|
|
@ -129,8 +129,9 @@ async function testTerminalCommand(
|
|||
sendText: jest.fn(),
|
||||
}
|
||||
|
||||
// Create terminal info
|
||||
// Create terminal info with running state
|
||||
const mockTerminalInfo = new Terminal(1, mockTerminal, "/test/path")
|
||||
mockTerminalInfo.running = true
|
||||
|
||||
// Add the terminal to the registry
|
||||
TerminalRegistry["terminals"] = [mockTerminalInfo]
|
||||
|
|
@ -150,9 +151,6 @@ async function testTerminalCommand(
|
|||
}
|
||||
})
|
||||
|
||||
// Execute the command
|
||||
terminalProcess.run(command)
|
||||
|
||||
// Set up event listeners to capture output
|
||||
let capturedOutput = ""
|
||||
terminalProcess.on("completed", (output) => {
|
||||
|
|
@ -181,6 +179,9 @@ async function testTerminalCommand(
|
|||
// Get the event handlers from the mock
|
||||
const eventHandlers = (vscode as any).__eventHandlers
|
||||
|
||||
// Execute the command first to set up the process
|
||||
terminalProcess.run(command)
|
||||
|
||||
// Trigger the start terminal shell execution event through VSCode mock
|
||||
if (eventHandlers.startTerminalShellExecution) {
|
||||
eventHandlers.startTerminalShellExecution({
|
||||
|
|
@ -192,10 +193,12 @@ async function testTerminalCommand(
|
|||
})
|
||||
}
|
||||
|
||||
// Wait a short time to ensure stream processing has started
|
||||
await new Promise((resolve) => setTimeout(resolve, 100))
|
||||
// Wait for some output to be processed
|
||||
await new Promise<void>((resolve) => {
|
||||
terminalProcess.once("line", () => resolve())
|
||||
})
|
||||
|
||||
// Trigger the end terminal shell execution event through VSCode mock
|
||||
// Then trigger the end event
|
||||
if (eventHandlers.endTerminalShellExecution) {
|
||||
eventHandlers.endTerminalShellExecution({
|
||||
terminal: mockTerminal,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue