test(webui): verify video player restarts playback after end

Add an e2e spec covering restart-on-end for the frame-accurate video
player. Drives the real player to its natural end (seek near the tail,
play out the last frames) and asserts both restart triggers resume from
the start: the play/pause control and clicking the video area.

Adds seekToFrame and waitForEnded helpers to VideoPlayerPage.
This commit is contained in:
yiling
2026-07-03 20:16:48 +08:00
parent 278bbdd4fe
commit 1de8c4ad32
2 changed files with 121 additions and 0 deletions
@@ -124,6 +124,36 @@ export class VideoPlayerPage {
}
}
/**
* Jump the native media clock to a given frame's center time via a real
* external seek (sets `video.currentTime`, which fires `seeked` and drives
* useFramePlayer). Used to land near the end of the clip so the "play to end"
* wait is short and deterministic instead of streaming the whole fixture.
*/
async seekToFrame(frame: number): Promise<void> {
await this.video.evaluate(
(el: HTMLVideoElement, args: { frame: number; fps: number }) => {
const frameDuration = 1 / args.fps
el.currentTime = args.frame * frameDuration + frameDuration / 2
},
{ frame, fps: SAMPLE_FRAME_RATE },
)
}
/** Wait until the native <video> element reports that playback has ended. */
async waitForEnded(timeout = 10_000): Promise<void> {
await this.video.evaluate(
(el: HTMLVideoElement) =>
el.ended
? Promise.resolve()
: new Promise<void>((resolve) => {
el.addEventListener('ended', () => resolve(), { once: true })
}),
undefined,
{ timeout },
)
}
clickPlayToggle(): Promise<void> {
return this.playToggle.click()
}