From 614bedd0ca40531986bf010a22b961fbf74d5f56 Mon Sep 17 00:00:00 2001 From: Jinjing <6427696+AmethystLiang@users.noreply.github.com> Date: Thu, 13 Aug 2026 09:30:49 -0700 Subject: [PATCH] test(e2e): bracket shell command output between markers The echoed command can wrap or be clipped by the buffer tail. Bracket output between begin and end markers to reliably identify real output, and strip ANSI escape sequences that interfere with parsing. --- tests/e2e/golden-shell-command.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/tests/e2e/golden-shell-command.spec.ts b/tests/e2e/golden-shell-command.spec.ts index ebc0b425c3c..4d3ee3b6832 100644 --- a/tests/e2e/golden-shell-command.spec.ts +++ b/tests/e2e/golden-shell-command.spec.ts @@ -1,3 +1,4 @@ +import { stripAnsiEscapeSequences } from '../../src/shared/ansi-escape-sequences' import { test, expect } from './helpers/orca-app' import { ensureTerminalVisible } from './helpers/store' import { @@ -63,9 +64,15 @@ test('seeded project terminal runs a typed shell command @golden', async ({ orca let expandedPath = '' await expect .poll(async () => { - const lines = (await getTerminalContent(orcaPage, 8_000)).split(/\r?\n/) - const beginLine = lines.findIndex((line) => line.includes(begin) && !line.includes(end)) - expandedPath = beginLine !== -1 ? (lines[beginLine + 1]?.trim() ?? '') : '' + // Why: the echoed command can wrap or be clipped by the buffer tail, so only a + // line that is exactly the marker — bracketed by both markers — is real output. + const lines = stripAnsiEscapeSequences(await getTerminalContent(orcaPage, 8_000)) + .split(/\r?\n/) + .map((line) => line.trim()) + const beginLine = lines.lastIndexOf(begin) + const endLine = beginLine === -1 ? -1 : lines.indexOf(end, beginLine + 1) + expandedPath = + endLine === -1 ? '' : (lines.slice(beginLine + 1, endLine).find(Boolean) ?? '') return expandedPath }) .not.toBe('')