Skip to content

Commit 09670d4

Browse files
Bill LeoutsakosBill Leoutsakos
authored andcommitted
test(desktop): wait for terminal writes to finish
1 parent b3e8d8e commit 09670d4

1 file changed

Lines changed: 4 additions & 5 deletions

File tree

‎apps/desktop/src/main/terminal/selection.test.ts‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { sleep } from '@sim/utils/helpers'
21
import { Terminal } from '@xterm/headless'
32
import { describe, expect, it } from 'vitest'
43
import { findSelectedRow } from '@/main/terminal/session'
@@ -7,14 +6,14 @@ const REVERSE = '\u001b[7m'
76
const RESET = '\u001b[0m'
87

98
/**
10-
* Writes to a real headless emulator and lets it settle, so these exercise the
11-
* same buffer the agent reads rather than a hand-built fake. xterm parses
12-
* asynchronously, hence the flush.
9+
* Writes to a real headless emulator and waits for the queued writes to finish,
10+
* so these exercise the same buffer the agent reads. The trailing empty write's
11+
* callback fires after xterm has parsed every preceding chunk.
1312
*/
1413
async function screen(write: (term: Terminal) => void, rows = 8): Promise<Terminal> {
1514
const term = new Terminal({ cols: 40, rows, allowProposedApi: true })
1615
write(term)
17-
await sleep(30)
16+
await new Promise<void>((resolve) => term.write('', resolve))
1817
return term
1918
}
2019

0 commit comments

Comments
 (0)