Skip to content

Commit

Permalink
Add regression E2E test for the classic block initialization issue (#…
Browse files Browse the repository at this point in the history
…25169)

Adds a regression test in the client block E2E spec to avoid the regression of the Classic block, per this issue:  #24696, as suggested in #25162 (comment).

Co-authored-by: Bernie Reiter <[email protected]>
  • Loading branch information
fullofcaffeine and ockham authored Sep 10, 2020
1 parent 7e8ab3a commit d7cda50
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
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"]' );

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();
} );
} );

0 comments on commit d7cda50

Please sign in to comment.