chore: bump version to 17.3.7
Retry: deflaked tui IME preedit border test (#5563) — VirtualTerminal.waitForRender's fixed 40ms sleep raced TUI's throttled render timer on starved CI runners, reading the pre-input frame; waitForRender now takes an optional settle predicate polled up to 2s and the test keys on the rendered content.
This commit is contained in:
@@ -1025,7 +1025,7 @@ describe("Editor component", () => {
|
||||
await terminal.waitForRender();
|
||||
for (const char of "ast") editor.handleInput(char);
|
||||
tui.requestRender();
|
||||
await terminal.waitForRender();
|
||||
await terminal.waitForRender(() => terminal.getViewport()[1]?.includes("ast") === true);
|
||||
|
||||
const beforePreedit = terminal.getViewport().map(row => row.trimEnd());
|
||||
expect(beforePreedit.slice(0, 3)).toEqual(["+------------------+", "| ast", "+------------------+"]);
|
||||
|
||||
@@ -280,12 +280,21 @@ export class VirtualTerminal implements Terminal {
|
||||
|
||||
// --- Test-only helpers ---------------------------------------------------
|
||||
|
||||
/** Wait for TUI's throttled render pipeline to settle (matches the ~33ms frame budget). */
|
||||
async waitForRender(): Promise<void> {
|
||||
/**
|
||||
* Wait for TUI's throttled render pipeline to settle (matches the ~33ms
|
||||
* frame budget). Fixed sleeps race starved CI timers, so callers asserting
|
||||
* on a specific frame pass `until`; polling continues (10ms slices, ~2s
|
||||
* cap) until the predicate observes the expected viewport.
|
||||
*/
|
||||
async waitForRender(until?: () => boolean): Promise<void> {
|
||||
const nextTick = Promise.withResolvers<void>();
|
||||
process.nextTick(nextTick.resolve);
|
||||
await nextTick.promise;
|
||||
await Bun.sleep(40);
|
||||
if (until) {
|
||||
const deadline = Date.now() + 2_000;
|
||||
while (!until() && Date.now() < deadline) await Bun.sleep(10);
|
||||
}
|
||||
await this.flush();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user