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

e2e test for reusable block after refresh. #20605

Merged
merged 1 commit into from
Apr 20, 2020
Merged
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
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