Skip to content

[test] Remove problematic 5000ms wait in the e2e's st_audio_input stop_recording#12540

Merged
sfc-gh-nbellante merged 2 commits intodevelopfrom
remove-problematic-waits
Sep 22, 2025
Merged

[test] Remove problematic 5000ms wait in the e2e's st_audio_input stop_recording#12540
sfc-gh-nbellante merged 2 commits intodevelopfrom
remove-problematic-waits

Conversation

@sfc-gh-nbellante
Copy link
Copy Markdown
Contributor

@sfc-gh-nbellante sfc-gh-nbellante commented Sep 16, 2025

Describe your changes

This pull request updates the end-to-end Playwright tests for audio input to better handle recording and downloading audio files, especially in iframe contexts. The main improvements include making the recording stop logic more robust and ensuring microphone permissions are granted in iframe tests.

Test robustness and iframe handling:

  • Modified the stop_recording function in st_audio_input_test.py to accept a wait_for_run parameter
  • Updated _test_download_audio_file to detect when running in an iframe and adjust waiting logic accordingly, ensuring reliable test execution in both normal and iframe contexts.
  • Ensured microphone permissions are granted before running audio input tests within iframes, improving test reliability.

Contribution License Agreement

By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.

@snyk-io
Copy link
Copy Markdown
Contributor

snyk-io bot commented Sep 16, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

license/snyk check is complete. No issues have been found. (View Details)

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 16, 2025

✅ PR preview is ready!

Name Link
📦 Wheel file https://core-previews.s3-us-west-2.amazonaws.com/pr-12540/streamlit-1.49.1-py3-none-any.whl
🕹️ Preview app pr-12540.streamlit.app (☁️ Deploy here if not accessible)

Copy link
Copy Markdown
Contributor Author

sfc-gh-nbellante commented Sep 16, 2025

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 16, 2025

📉 Frontend coverage change detected

The frontend unit test (vitest) coverage has decreased by 0.0000%

  • Current PR: 84.9200% (47604 lines, 7174 missed)
  • Latest develop: 84.9200% (47604 lines, 7174 missed)

✅ Coverage change is within normal range.

📊 View detailed coverage comparison

@sfc-gh-nbellante sfc-gh-nbellante force-pushed the remove-problematic-waits branch 3 times, most recently from 7ad371f to 31a610e Compare September 16, 2025 17:46
Replace arbitrary 5-second timeout with proper expectations:
- Wait for app run to complete
- Verify waveform is visible after recording

This fixes race condition masking issue where tests could pass even if the recording wasn't properly processed.
@sfc-gh-nbellante sfc-gh-nbellante changed the base branch from graphite-base/12540 to develop September 19, 2025 20:25
@sfc-gh-nbellante sfc-gh-nbellante marked this pull request as ready for review September 19, 2025 20:30
stop_recording(audio_input, app, wait_for_run=not is_iframe)
if is_iframe:
# Give iframe time to process the recording
app.wait_for_timeout(2000)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Streamlit E2E Tests guide explicitly states 'Never use wait_for_timeout' and recommends using the 'wait_until' utility instead. The line 'app.wait_for_timeout(2000)' violates this best practice. Replace this with a proper wait condition using the wait_until utility to wait for a specific state or element rather than an arbitrary timeout.

Suggested change
app.wait_for_timeout(2000)
app.wait_until(lambda: app.get_by_test_id("stAudioInput").is_visible())

Spotted by Diamond (based on custom rule: E2E Playwright Tests)

Fix in Graphite


Is this helpful? React 👍 or 👎 to let us know.

- Replace wait_for_timeout(2000) with expect().to_be_visible()
- Only change the line that was already modified in this PR to avoid conflicts
- Follow E2E test best practice: avoid wait_for_timeout where possible
@sfc-gh-nbellante sfc-gh-nbellante changed the title [test] Remove problematic 5000ms wait in stop_recording [test] Remove problematic 5000ms wait in the e2e's st_audio_input stop_recording Sep 19, 2025
@sfc-gh-nbellante sfc-gh-nbellante merged commit 28db558 into develop Sep 22, 2025
39 checks passed
@sfc-gh-nbellante sfc-gh-nbellante deleted the remove-problematic-waits branch September 22, 2025 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:chore PR contains maintenance or housekeeping change impact:internal PR changes only affect internal code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants