[test] Remove problematic 5000ms wait in the e2e's st_audio_input stop_recording#12540
[test] Remove problematic 5000ms wait in the e2e's st_audio_input stop_recording#12540sfc-gh-nbellante merged 2 commits intodevelopfrom
Conversation
🎉 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) |
✅ PR preview is ready!
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
📉 Frontend coverage change detectedThe frontend unit test (vitest) coverage has decreased by 0.0000%
✅ Coverage change is within normal range. |
7ad371f to
31a610e
Compare
862e096 to
8f0bfeb
Compare
31a610e to
6b27475
Compare
8f0bfeb to
0d8f61d
Compare
6b27475 to
0e0fb7d
Compare
06d4203 to
f49c9f8
Compare
0e0fb7d to
8f07a70
Compare
f49c9f8 to
91dfac1
Compare
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.
91dfac1 to
b3a1e33
Compare
8f07a70 to
71fe8f0
Compare
| 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) |
There was a problem hiding this comment.
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.
| 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)
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

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:
stop_recordingfunction inst_audio_input_test.pyto accept await_for_runparameter_test_download_audio_fileto detect when running in an iframe and adjust waiting logic accordingly, ensuring reliable test execution in both normal and iframe contexts.Contribution License Agreement
By submitting this pull request you agree that all contributions to this project are made under the Apache 2.0 license.