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

Add regression E2E test for the classic block initialization issue #25169

Merged
merged 8 commits into from
Sep 10, 2020
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
@@ -1,3 +1,5 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Classic Should not fail after save/reload 1`] = `"test"`;

exports[`Classic should be inserted 1`] = `"test"`;
40 changes: 40 additions & 0 deletions packages/e2e-tests/specs/editor/blocks/classic.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
insertBlock,
pressKeyWithModifier,
clickBlockToolbarButton,
saveDraft,
} from '@wordpress/e2e-test-utils';

describe( 'Classic', () => {
Expand Down Expand Up @@ -46,6 +47,7 @@ describe( 'Classic', () => {
// Click the image button.
await page.waitForSelector( 'div[aria-label^="Add Media"]' );
await page.click( 'div[aria-label^="Add Media"]' );

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

await page.click( '.media-menu-item#menu-item-gallery' );

// Wait for media modal to appear and upload image.
Expand Down Expand Up @@ -98,4 +100,42 @@ describe( 'Classic', () => {
await page.waitForSelector( '.wp-block[data-type="core/gallery"]' );
expect( await getEditedPostContent() ).toMatch( /<!-- wp:gallery/ );
} );

it( 'Should not fail after save/reload', async () => {
// Might move to utils if this becomes useful enough for other tests
const runWithoutCache = async ( cb ) => {
try {
await page.setCacheEnabled( false );
await cb();
} finally {
await page.setCacheEnabled( true );
}
};

await insertBlock( 'Classic' );

// Wait for TinyMCE to initialise.
await page.waitForSelector( '.mce-content-body' );

// Ensure there is focus.
await page.focus( '.mce-content-body' );
await page.keyboard.type( 'test' );

// Move focus away.
await pressKeyWithModifier( 'shift', 'Tab' );

// Save
await saveDraft();

// Reload
// Disabling the browser disk cache is needed in order to reproduce the issue
// in case it regresses. To test this, revert commit 65c9f74, build and run the test.
await runWithoutCache( () => page.reload() );

const classicBlockSelector = 'div[aria-label^="Block: Classic"]';
await page.waitForSelector( classicBlockSelector );
await page.focus( classicBlockSelector );
expect( console ).not.toHaveErrored();
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
} );