From 1de8c4ad32bc428565910bcef8f65ece03c3a47f Mon Sep 17 00:00:00 2001 From: yiling Date: Fri, 3 Jul 2026 20:16:48 +0800 Subject: [PATCH] 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. --- packages/webui/e2e/pages/video-player.page.ts | 30 ++++++ .../webui/e2e/tests/restart-on-end.spec.ts | 91 +++++++++++++++++++ 2 files changed, 121 insertions(+) create mode 100644 packages/webui/e2e/tests/restart-on-end.spec.ts diff --git a/packages/webui/e2e/pages/video-player.page.ts b/packages/webui/e2e/pages/video-player.page.ts index 9e0f6565..6a3dbf90 100644 --- a/packages/webui/e2e/pages/video-player.page.ts +++ b/packages/webui/e2e/pages/video-player.page.ts @@ -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 { + 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