diff --git a/packages/block-editor/src/components/index.native.js b/packages/block-editor/src/components/index.native.js index ac4b45af3609ca..debf5a074a07a9 100644 --- a/packages/block-editor/src/components/index.native.js +++ b/packages/block-editor/src/components/index.native.js @@ -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'; diff --git a/packages/block-library/src/media-text/media-container.native.js b/packages/block-library/src/media-text/media-container.native.js index ec6e3999807c8e..a337cecc2c4891 100644 --- a/packages/block-library/src/media-text/media-container.native.js +++ b/packages/block-library/src/media-text/media-container.native.js @@ -341,7 +341,9 @@ class MediaContainer extends Component { { getMediaOptions() } { + 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(); + } ); +} ); diff --git a/packages/react-native-editor/CHANGELOG.md b/packages/react-native-editor/CHANGELOG.md index ecd7457c3f1ed9..2aa15c90271145 100644 --- a/packages/react-native-editor/CHANGELOG.md +++ b/packages/react-native-editor/CHANGELOG.md @@ -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]