mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 13:47:58 +00:00
test(webui): add e2e test to verify playhead advances immediately for audio assets
This commit is contained in:
Binary file not shown.
@@ -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,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user