Skip to content

Commit b1b7336

Browse files
committed
fix(tests): replace racy literal text with echo command in waiter test
why: Test was flaky - literal=True sends raw keystrokes that can be captured mid-render, resulting in corrupted text (e.g., "NIQUE_TEST_STRING_123c") what: - Replace send_keys with literal=True with echo command - Use wait_for_pane_content to wait for output instead of time.sleep() - Increase timeout to 5.0s for CI reliability
1 parent 09e62ac commit b1b7336

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

tests/_internal/test_waiter.py

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,34 +1842,21 @@ def test_wait_for_pane_content_exact_match_detailed(wait_pane: Pane) -> None:
18421842
match type is handled, including the code path where a match
18431843
is found and validated.
18441844
"""
1845-
# Clear the pane first to have more predictable content
1845+
# Clear and execute a command that produces predictable output
18461846
wait_pane.clear()
1847+
wait_pane.send_keys("echo 'UNIQUE_TEST_STRING_123'")
18471848

1848-
# Send a unique string that we can test with an exact match
1849-
wait_pane.send_keys("UNIQUE_TEST_STRING_123", literal=True)
1850-
1851-
# Small delay to allow tmux to flush content (needed for older versions like 3.1b)
1852-
time.sleep(0.1)
1853-
1854-
# Get the current content to work with
1855-
content = wait_pane.capture_pane()
1856-
content_str = "\n".join(content if isinstance(content, list) else [content])
1857-
1858-
# Verify our test string is in the content
1859-
assert "UNIQUE_TEST_STRING_123" in content_str
1860-
1861-
# Test with CONTAINS match type first (more reliable)
1849+
# Use the waiter itself to wait for the string (dogfooding!)
18621850
result = wait_for_pane_content(
18631851
wait_pane,
18641852
"UNIQUE_TEST_STRING_123",
18651853
ContentMatchType.CONTAINS,
1866-
timeout=1.0,
1867-
interval=0.1,
1854+
timeout=5.0,
18681855
)
1869-
assert result.success
1856+
assert result.success, f"String not found: {result.error}"
18701857

1871-
# Now test with EXACT match but with a simpler approach
1872-
# Find the exact line that contains our test string
1858+
# Now get the content and find the exact line for EXACT match testing
1859+
content = wait_pane.capture_pane()
18731860
exact_line = next(
18741861
(line for line in content if "UNIQUE_TEST_STRING_123" in line),
18751862
"UNIQUE_TEST_STRING_123",

0 commit comments

Comments
 (0)