Skip to content

Commit

Permalink
Add test for new API
Browse files Browse the repository at this point in the history
It fails :(
  • Loading branch information
getdave committed May 12, 2023
1 parent b163447 commit 6bf6d37
Showing 1 changed file with 22 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,56 +47,27 @@ describe( 'Prioritized Inserter Blocks Setting on InnerBlocks', () => {
await expect( await getAllBlockInserterItemTitles() ).toHaveLength( 6 );
} );

// it( 'allows the blocks if the allowed blocks setting was set', async () => {
// const parentBlockSelector = '[data-type="test/prioritized-inner-block-set"]';
// const childParagraphSelector = `${ parentBlockSelector } ${ imageBlockSelector }`;
// await insertBlock( 'Prioritized Inserter Blocks Set' );
// await closeGlobalBlockInserter();
// await page.waitForSelector( childParagraphSelector );
// await page.click( childParagraphSelector );
// await openGlobalBlockInserter();
// expect( await getAllBlockInserterItemTitles() ).toEqual( [
// 'Button',
// 'Gallery',
// 'List',
// 'Media & Text',
// 'Quote',
// ] );
// } );
it( 'uses the priority ordering if prioritzed blocks setting is set', async () => {
const parentBlockSelector =
'[data-type="test/prioritized-inserter-blocks-set"]';
await insertBlock( 'Prioritized Inserter Blocks Set' );
await closeGlobalBlockInserter();

await page.waitForSelector( parentBlockSelector );

await page.click(
`${ parentBlockSelector } .block-list-appender .block-editor-inserter__toggle`
);

await page.waitForSelector( QUICK_INSERTER_RESULTS_SELECTOR );

// Should still be only 6 results regardless of the priority ordering.
const inserterItems = await getAllBlockInserterItemTitles();

// it( 'correctly applies dynamic allowed blocks restrictions', async () => {
// await insertBlock( 'Prioritized Inserter Blocks Dynamic' );
// await closeGlobalBlockInserter();
// const parentBlockSelector = '[data-type="test/prioritized-inner-block-dynamic"]';
// const blockAppender = '.block-list-appender button';
// const appenderSelector = `${ parentBlockSelector } ${ blockAppender }`;
// await page.waitForSelector( appenderSelector );
// await page.click( appenderSelector );
// expect( await getAllBlockInserterItemTitles() ).toEqual( [
// 'Image',
// 'List',
// ] );
// const insertButton = (
// await page.$x( `//button//span[contains(text(), 'List')]` )
// )[ 0 ];
// await insertButton.click();
// // Select the list wrapper so the image is inserable.
// await page.keyboard.press( 'ArrowUp' );
// await insertBlock( 'Image' );
// await closeGlobalBlockInserter();
// await page.waitForSelector( '.product[data-number-of-children="2"]' );
// await clickBlockToolbarButton(
// 'Select Prioritized Inserter Blocks Dynamic'
// );
// // This focus shouldn't be neessary but there's a bug in trunk right now
// // Where if you open the inserter, don't do anything and click the "appender" on the canvas
// // the appender is not opened right away.
// // It needs to be investigated on its own.
// await page.focus( appenderSelector );
// await page.click( appenderSelector );
// expect( await getAllBlockInserterItemTitles() ).toEqual( [
// 'Gallery',
// 'Video',
// ] );
// } );
expect( inserterItems.slice( 0, 2 ) ).toEqual( [
'Audio',
'Spacer',
'Code',
] );
} );
} );

0 comments on commit 6bf6d37

Please sign in to comment.