From 072fe75e69d8a2592f7bbe8d7a7d2aeb7de79f2a Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Mon, 21 Oct 2024 00:05:16 -0700 Subject: [PATCH] test: Fix DOM autosetup test flake (#7448) The promise for DOM auto setup tests doesn't guarantee that load() is complete, only that we started it. So checking video duration causes flake, in particular on slow devices like Tizen. Instead, check for the player to have an asset URI. --- test/ui/ui_unit.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/ui/ui_unit.js b/test/ui/ui_unit.js index 72d757caf..8c09d12bb 100644 --- a/test/ui/ui_unit.js +++ b/test/ui/ui_unit.js @@ -90,8 +90,12 @@ describe('UI', () => { }); it('has loaded the video', () => { - expect(video.duration).not.toBeNaN(); - expect(video.duration).not.toBe(0); + // The above promise for DOMAutoSetup() doesn't guarantee that load() + // is complete, only that we started it. So don't check duration or + // other things that require load() to complete. + const overlay = /** @type {!shaka.ui.Overlay} */(video['ui']); + const player = overlay.getControls().getPlayer(); + expect(player.getAssetUri()).toBeTruthy(); }); }); @@ -118,8 +122,12 @@ describe('UI', () => { }); it('has loaded the video', () => { - expect(video.duration).not.toBeNaN(); - expect(video.duration).not.toBe(0); + // The above promise for DOMAutoSetup() doesn't guarantee that load() + // is complete, only that we started it. So don't check duration or + // other things that require load() to complete. + const overlay = /** @type {!shaka.ui.Overlay} */(video['ui']); + const player = overlay.getControls().getPlayer(); + expect(player.getAssetUri()).toBeTruthy(); }); });