Skip to content

Commit

Permalink
Add test.
Browse files Browse the repository at this point in the history
  • Loading branch information
sainthkh authored and noisysocks committed Apr 20, 2020
1 parent fa16fa3 commit 9e08a5b
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions packages/e2e-tests/specs/editor/various/reusable-blocks.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,56 @@ describe( 'Reusable blocks', () => {
expect( text ).toMatch( 'Oh! Hello there!' );
} );

it( 'can be inserted after refresh', async () => {
// Step 1. Insert a paragraph block

await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Awesome Paragraph' );

await clickBlockToolbarButton( 'More options' );

const convertButton = await page.waitForXPath(
'//button[text()="Add to Reusable blocks"]'
);
await convertButton.click();

// Wait for creation to finish
await page.waitForXPath(
'//*[contains(@class, "components-snackbar")]/*[text()="Block created."]'
);

// Select all of the text in the title field.
await pressKeyWithModifier( 'primary', 'a' );

// Give the reusable block a title
await page.keyboard.type( 'Awesome block' );

// Save the reusable block
const [ saveButton ] = await page.$x( '//button[text()="Save"]' );
await saveButton.click();

// Step 2. Create new post.

await createNewPost();

// Step 3. Insert the block created in Step 1.

await insertBlock( 'Awesome block' );

// Check that we have a reusable block on the page
const block = await page.$(
'.block-editor-block-list__block[data-type="core/block"]'
);
expect( block ).not.toBeNull();

// Check that its title is displayed
const title = await page.$eval(
'.reusable-block-edit-panel__info',
( element ) => element.innerText
);
expect( title ).toBe( 'Awesome block' );
} );

it( 'can be converted to a regular block', async () => {
// Insert the reusable block we edited above
await insertBlock( 'Surprised greeting block' );
Expand Down

0 comments on commit 9e08a5b

Please sign in to comment.