feat: make media inspection progressive
This commit is contained in:
@@ -43,7 +43,7 @@ describe('MediaPreview', () => {
|
||||
expect(progressiveVideo).toHaveAttribute('src', probingAsset.objectUrl);
|
||||
expect(
|
||||
screen.getByText(
|
||||
'Local source preview · Media inspection continues in the background.'
|
||||
'Local source preview · Detailed inspection runs separately.'
|
||||
)
|
||||
).toBeVisible();
|
||||
|
||||
@@ -61,6 +61,64 @@ describe('MediaPreview', () => {
|
||||
expect(container.querySelector('video')).toBe(progressiveVideo);
|
||||
});
|
||||
|
||||
it('keeps browser playback mounted after detailed inspection fails', () => {
|
||||
const asset: ImportedMediaAsset = {
|
||||
id: 'asset-probe-error',
|
||||
file: new File(['video'], 'lecture.mp4', { type: 'video/mp4' }),
|
||||
objectUrl: 'blob:probe-error',
|
||||
phase: 'error',
|
||||
error: 'Detailed inspection timed out.',
|
||||
};
|
||||
|
||||
const { container } = render(<MediaPreview asset={asset} />);
|
||||
|
||||
expect(container.querySelector('video')).toHaveAttribute(
|
||||
'src',
|
||||
asset.objectUrl
|
||||
);
|
||||
expect(
|
||||
screen.getByText(
|
||||
'Local source preview · Detailed inspection unavailable.'
|
||||
)
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
it('keeps the video-container player when browser metadata has no track hints', () => {
|
||||
const file = new File(['audio-only'], 'audio-only.mp4', {
|
||||
type: 'video/mp4',
|
||||
});
|
||||
const initial: ImportedMediaAsset = {
|
||||
id: 'asset-audio-only-container',
|
||||
file,
|
||||
objectUrl: 'blob:audio-only-container',
|
||||
phase: 'idle',
|
||||
};
|
||||
const { container, rerender } = render(<MediaPreview asset={initial} />);
|
||||
const player = requiredElement(container.querySelector('video'));
|
||||
|
||||
rerender(
|
||||
<MediaPreview
|
||||
asset={{
|
||||
...initial,
|
||||
browserMetadata: {
|
||||
source: 'browser',
|
||||
file: {
|
||||
name: file.name,
|
||||
sizeBytes: file.size,
|
||||
declaredMimeType: file.type,
|
||||
inferredMimeType: file.type,
|
||||
lastModified: file.lastModified,
|
||||
},
|
||||
kind: 'video',
|
||||
durationSeconds: 8,
|
||||
},
|
||||
}}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(container.querySelector('video')).toBe(player);
|
||||
});
|
||||
|
||||
it('offers bounded configurable proxy settings after playback fails', async () => {
|
||||
const user = userEvent.setup();
|
||||
const onCreateProxy = vi.fn();
|
||||
|
||||
Reference in New Issue
Block a user