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

Audio block: Add integration tests to cover enabling autoplay and loop setting in Audio block #57715

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -532,3 +532,15 @@ exports[`Audio block renders placeholder without crashing 1`] = `
</View>
</View>
`;

exports[`Audio block should enable autoplay setting 1`] = `
"<!-- wp:audio {"id":5} -->
<figure class="wp-block-audio"><audio controls src="https://cldup.com/59IrU0WJtq.mp3" autoplay></audio></figure>
<!-- /wp:audio -->"
`;

exports[`Audio block should enable loop setting 1`] = `
"<!-- wp:audio {"id":5} -->
<figure class="wp-block-audio"><audio controls src="https://cldup.com/59IrU0WJtq.mp3" loop></audio></figure>
<!-- /wp:audio -->"
`;
29 changes: 29 additions & 0 deletions packages/block-library/src/audio/test/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import {
addBlock,
dismissModal,
fireEvent,
getBlock,
getEditorHtml,
initializeEditor,
openBlockSettings,
render,
screen,
setupCoreBlocks,
Expand All @@ -31,6 +34,10 @@ jest.unmock( '@wordpress/react-native-aztec' );

const MEDIA_UPLOAD_STATE_FAILED = 3;

const AUDIO_BLOCK = `<!-- wp:audio {"id":5} -->
<figure class="wp-block-audio"><audio controls src="https://cldup.com/59IrU0WJtq.mp3"></audio></figure>
<!-- /wp:audio -->`;

let uploadCallBack;
subscribeMediaUpload.mockImplementation( ( callback ) => {
uploadCallBack = callback;
Expand Down Expand Up @@ -100,4 +107,26 @@ describe( 'Audio block', () => {
screen.getByText( 'Invalid URL. Audio file not found.' )
).toBeVisible();
} );

it( 'should enable autoplay setting', async () => {
await initializeEditor( { initialHtml: AUDIO_BLOCK } );

const audioBlock = getBlock( screen, 'Audio' );
fireEvent.press( audioBlock );
await openBlockSettings( screen );

fireEvent.press( screen.getByText( 'Autoplay' ) );
expect( getEditorHtml() ).toMatchSnapshot();
} );

it( 'should enable loop setting', async () => {
await initializeEditor( { initialHtml: AUDIO_BLOCK } );

const audioBlock = getBlock( screen, 'Audio' );
fireEvent.press( audioBlock );
await openBlockSettings( screen );

fireEvent.press( screen.getByText( 'Loop' ) );
expect( getEditorHtml() ).toMatchSnapshot();
} );
} );
Loading