test(webui): add e2e test to verify playhead advances immediately for audio assets

This commit is contained in:
yiling
2026-07-05 15:28:18 +08:00
parent e511af219e
commit f24c8afa3d
5 changed files with 64 additions and 0 deletions
Binary file not shown.
+24
View File
@@ -136,3 +136,27 @@ export const longAudioVideoAsset: AssetInfo = {
},
},
}
export const SAMPLE_AUDIO_URL = '/sample-audio.mp4'
export const SAMPLE_AUDIO_DURATION = 3.0
export const SAMPLE_AUDIO_COMPUTED_TOTAL_FRAMES = Math.round(SAMPLE_AUDIO_DURATION * SAMPLE_FRAME_RATE)
export const sampleAudioAsset: AssetInfo = {
...sampleVideoAsset,
id: 'e2e-sample-audio-asset',
name: 'sample-audio.mp4',
mediaType: 'audio/mp4',
media: {
original: {
downloadUrl: SAMPLE_AUDIO_URL,
key: 'sample-audio.mp4',
},
metadata: {
duration: SAMPLE_AUDIO_DURATION,
originalWidth: 0,
originalHeight: 0,
frameRate: SAMPLE_FRAME_RATE,
totalFrames: SAMPLE_AUDIO_COMPUTED_TOTAL_FRAMES,
},
},
}
+2
View File
@@ -9,6 +9,7 @@ import {
sampleVideoAsset,
containerLongerVideoAsset,
longAudioVideoAsset,
sampleAudioAsset,
} from './fixture'
/**
@@ -58,6 +59,7 @@ function resolveAsset() {
: null
if (variant === 'container-longer') return containerLongerVideoAsset
if (variant === 'long-audio') return longAudioVideoAsset
if (variant === 'audio') return sampleAudioAsset
return sampleVideoAsset
}
+4
View File
@@ -30,6 +30,10 @@ const server = Bun.serve({
new Response(Bun.file(join(fixturesDir, 'sample-long-audio.mp4')), {
headers: { 'Content-Type': 'video/mp4' },
}),
'/sample-audio.mp4': () =>
new Response(Bun.file(join(fixturesDir, 'sample-audio.mp4')), {
headers: { 'Content-Type': 'video/mp4' },
}),
'/': index,
'/*': index,
},
@@ -0,0 +1,34 @@
import { expect, test } from '@playwright/test'
import { VideoPlayerPage } from '../pages/video-player.page'
test.beforeEach(async ({ page }) => {
await page.route(/^https?:\/\/[^/]+\/(api|files)\//, (route) =>
route.fulfill({ status: 200, contentType: 'application/json', body: '{}' }),
)
})
test.describe('audio player e2e', () => {
test('playhead advances immediately without freeze on play', async ({ page }) => {
const vp = new VideoPlayerPage(page)
await vp.gotoVariant('audio')
await vp.muteNativeVideo()
// Starts paused at frame 0.
const initial = await vp.snapshot()
expect(initial.paused).toBe(true)
expect(initial.readoutFrame).toBe(0)
// Play via the control
await vp.clickPlayToggle()
await expect.poll(() => vp.isPaused(), { timeout: 5_000 }).toBe(false)
// Wait for 300ms. If the playhead froze (which happened under the bug where
// it waited 1000ms for rVFC grace period), readoutFrame would still be 0.
// With the fix, the playhead should advance immediately.
await page.waitForTimeout(300)
const afterPlay = await vp.snapshot()
expect(afterPlay.readoutFrame).toBeGreaterThan(0)
expect(afterPlay.currentTime).toBeGreaterThan(0)
})
})