From 5687a2c2277d271b49f0a1c16df4538fc656a4d2 Mon Sep 17 00:00:00 2001 From: Neil <4138956+nwparker@users.noreply.github.com> Date: Wed, 29 Jul 2026 07:15:47 -0700 Subject: [PATCH] test(terminal): make restore promotion ordering deterministic --- .../terminal-pane/pty-connection.test.ts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/renderer/src/components/terminal-pane/pty-connection.test.ts b/src/renderer/src/components/terminal-pane/pty-connection.test.ts index e6870ff5d50..b536e6744e6 100644 --- a/src/renderer/src/components/terminal-pane/pty-connection.test.ts +++ b/src/renderer/src/components/terminal-pane/pty-connection.test.ts @@ -14003,12 +14003,21 @@ describe('connectPanePty', () => { const getMainBufferSnapshot = window.api.pty.getMainBufferSnapshot as unknown as ReturnType< typeof vi.fn > - getMainBufferSnapshot.mockResolvedValue({ + const promotedSnapshot = { data: 'promoted snapshot\r\n', cols: 100, rows: 30, seq: 64 - }) + } + const promotedSnapshotResolver: { + current: ((snapshot: typeof promotedSnapshot) => void) | null + } = { current: null } + getMainBufferSnapshot.mockImplementation( + () => + new Promise((resolve) => { + promotedSnapshotResolver.current = resolve + }) + ) const pane = createPane(1) const manager = createManager(1, 1) @@ -14036,6 +14045,9 @@ describe('connectPanePty', () => { expect(blockingRestore).not.toHaveBeenCalled() expect(getMainBufferSnapshot).toHaveBeenCalledWith('pty-id', { scrollbackRows: 5000 }) + expect(promotedSnapshotResolver.current).not.toBeNull() + promotedSnapshotResolver.current?.(promotedSnapshot) + await flushAsyncTicks(20) expect(pane.terminal.write).toHaveBeenCalledWith( expect.stringContaining('promoted snapshot'), expect.any(Function)