Skip to content

Commit

Permalink
Try fixing block-directory-add.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
WunderBart committed Dec 8, 2022
1 parent 2bdb501 commit 102c126
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions packages/e2e-tests/specs/editor/plugins/block-directory-add.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/
import {
createNewPost,
searchForBlock,
searchForBlockDirectoryBlock,
insertBlockDirectoryBlock,
setUpResponseMocking,
getEditedPostContent,
Expand Down Expand Up @@ -142,7 +142,13 @@ const MOCK_BLOCKS_RESPONSES = [
// Mock the post-new page as requested via apiFetch for determining new CSS/JS assets.
match: ( request ) => request.url().includes( '/post-new.php' ),
onRequestMatch: createResponse(
`<html><head><script id="mock-block-js" src="${ MOCK_BLOCK1.assets[ 0 ] }"></script></head><body/></html>`,
`<!DOCTYPE html>
<html>
<head>
<script id="mock-block-js" src="${ MOCK_BLOCK1.assets[ 0 ] }"></script>
</head>
<body></body>
</html>`,
'text/html; charset=UTF-8'
),
},
Expand Down Expand Up @@ -178,19 +184,17 @@ describe( 'adding blocks from block directory', () => {
await setUpResponseMocking( MOCK_EMPTY_RESPONSES );

// Search for the block via the inserter.
await searchForBlock( impossibleBlockName );

const selectorContent = await page.evaluate(
() =>
document.querySelector( '.block-editor-inserter__main-area' )
.innerHTML
);
expect( selectorContent ).toContain(
'block-editor-inserter__no-results'
const searchResult = await searchForBlockDirectoryBlock(
impossibleBlockName
);

// null means no results.
expect( searchResult ).toBe( null );
} );

it( 'Should be able to add (the first) block.', async () => {
await page.waitForFunction( () => window.wp );

// Setup our mocks.
await setUpResponseMocking( MOCK_BLOCKS_RESPONSES );

Expand Down

0 comments on commit 102c126

Please sign in to comment.