-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Media & Text block displays video upload errors (#59288)
* fix: Media & Text block displays video upload errors When the paused state and messaging was implemented for image uploads, it was inadvertently applied to Media & Text blocks. This resulted in a lack of any failed upload messages when a video was attached to the Media & Text block. * test: Media & Text block displays video upload errors * docs: Add change log entry
- Loading branch information
Showing
4 changed files
with
63 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
908e3ed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Flaky tests detected in 908e3ed.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.
🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/8012923966
📝 Reported issues:
/test/e2e/specs/editor/blocks/navigation-list-view.spec.js