Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Media & Text block displays video upload errors #59288

Merged
merged 3 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export { default as MediaUploadProgress } from './media-upload-progress';
export {
MEDIA_UPLOAD_STATE_UPLOADING,
MEDIA_UPLOAD_STATE_SUCCEEDED,
MEDIA_UPLOAD_STATE_PAUSED,
MEDIA_UPLOAD_STATE_FAILED,
MEDIA_UPLOAD_STATE_RESET,
} from './media-upload-progress/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,9 @@ class MediaContainer extends Component {
{ getMediaOptions() }

<MediaUploadProgress
enablePausedUploads
enablePausedUploads={
mediaType === MEDIA_TYPE_IMAGE
}
coverUrl={ coverUrl }
mediaId={ mediaId }
onUpdateMediaProgress={
Expand Down
58 changes: 58 additions & 0 deletions packages/block-library/src/media-text/test/edit.native.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/**
* External dependencies
*/
import {
addBlock,
fireEvent,
initializeEditor,
screen,
setupCoreBlocks,
} from 'test/helpers';

/**
* WordPress dependencies
*/
import {
requestMediaPicker,
sendMediaUpload,
subscribeMediaUpload,
} from '@wordpress/react-native-bridge';
import { MEDIA_UPLOAD_STATE_PAUSED } from '@wordpress/block-editor';

let uploadCallBack;
subscribeMediaUpload.mockImplementation( ( callback ) => {
uploadCallBack = callback;
} );
sendMediaUpload.mockImplementation( ( payload ) => {
uploadCallBack( payload );
} );

setupCoreBlocks( [ 'core/media-text' ] );

describe( 'Media & Text block edit', () => {
it( 'should display an error message for failed video uploads', async () => {
requestMediaPicker.mockImplementation(
( source, filter, multiple, callback ) => {
callback( {
id: 1,
url: 'file://video.mp4',
type: 'video',
} );
}
);
await initializeEditor();
await addBlock( screen, 'Media & Text' );
fireEvent.press( screen.getByText( 'Add image or video' ) );
fireEvent.press( screen.getByText( 'Choose from device' ) );

sendMediaUpload( {
mediaId: 1,
state: MEDIA_UPLOAD_STATE_PAUSED,
progress: 0,
} );

expect(
screen.getByText( 'Failed to insert media.\nTap for more info.' )
).toBeVisible();
} );
} );
1 change: 1 addition & 0 deletions packages/react-native-editor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ For each user feature we should also add a importance categorization label to i

## Unreleased
- [*] Prevent crash when autoscrolling to blocks [#59110]
- [*] Media & Text blocks correctly show an error message when the attached video upload fails [#59288]

## 1.112.0
- [*] [internal] Upgrade React Native to version 0.71.15 [#57667]
Expand Down
Loading