tests: fix a flaky test in chives-video
- ID
db7a622- date
2026-11-20 08:22:32+00:00- author
Alex Chan <alex@alexwlchan.net>- parent
8104a4e- message
tests: fix a flaky test in chives-video There's a timing race condition that made this test flaky, because the <track> element might not be rendered yet. Switch to the expect() function, which should be more reliable.- changed files
1 file, 5 additions, 5 deletions
Changed files
tests/javascript/test_chives_video.py (7022 → 6993)
diff --git a/tests/javascript/test_chives_video.py b/tests/javascript/test_chives_video.py
index 78db232..57dd329 100644
--- a/tests/javascript/test_chives_video.py
+++ b/tests/javascript/test_chives_video.py
@@ -199,12 +199,12 @@ def test_sets_subtitles(page: Page) -> None:
chives_elem = page.locator("chives-video")
- video_elem = chives_elem.locator("video")
- assert video_elem.locator("track").count() == 2
+ tracks = chives_elem.locator("video track")
+ expect(tracks).to_have_count(2)
- first_track = video_elem.locator("track").first
- assert first_track.get_attribute("label") == "English"
- assert first_track.get_attribute("src") == "wings_tracking_shot.en.vtt"
+ first_track = tracks.first
+ expect(first_track).to_have_attribute("label", "English")
+ expect(first_track).to_have_attribute("src", "wings_tracking_shot.en.vtt")
@pytest.mark.parametrize("subtitle_label", ["English (CC)"])