Skip to content

Commit

Permalink
Fix end2end tests
Browse files Browse the repository at this point in the history
  • Loading branch information
youknowriad committed Jul 16, 2020
1 parent 18e66ec commit dc2c833
Show file tree
Hide file tree
Showing 14 changed files with 29 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/e2e-test-utils/src/click-block-appender.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,8 @@
* Clicks the default block appender.
*/
export async function clickBlockAppender() {
await page.click( '.block-editor-default-block-appender__content' );
const appender = await page.waitForSelector(
'.block-editor-default-block-appender__content'
);
await appender.click();
}
3 changes: 3 additions & 0 deletions packages/e2e-test-utils/src/create-new-post.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export async function createNewPost( {

await visitAdminPage( 'post-new.php', query );

await page.waitForSelector( '.edit-post-layout' );

const isWelcomeGuideActive = await page.evaluate( () =>
wp.data.select( 'core/edit-post' ).isFeatureActive( 'welcomeGuide' )
);
Expand All @@ -47,6 +49,7 @@ export async function createNewPost( {
);

await page.reload();
await page.waitForSelector( '.edit-post-layout' );
}

if ( isFullscreenMode ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe( 'Block with a meta attribute', () => {

await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

expect( await getEditedPostContent() ).toMatchSnapshot();
const persistedValue = await page.evaluate(
Expand Down Expand Up @@ -86,6 +87,7 @@ describe( 'Block with a meta attribute', () => {

await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

expect( await getEditedPostContent() ).toMatchSnapshot();
const persistedValue = await page.evaluate(
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-tests/specs/editor/plugins/plugins-api.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@ describe( 'Using Plugins API', () => {
'.interface-complementary-area-header button[aria-label="Close plugin"]'
);
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
expect( await page.$( SIDEBAR_PINNED_ITEM_BUTTON ) ).toBeNull();
await clickOnMoreMenuItem( 'Sidebar title plugin' );
await page.click( 'button[aria-label="Pin to toolbar"]' );
expect( await page.$( SIDEBAR_PINNED_ITEM_BUTTON ) ).not.toBeNull();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
expect( await page.$( SIDEBAR_PINNED_ITEM_BUTTON ) ).not.toBeNull();
} );

Expand Down
3 changes: 3 additions & 0 deletions packages/e2e-tests/specs/editor/plugins/templates.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe( 'templates', () => {
await page.keyboard.press( 'Backspace' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Expand All @@ -53,6 +54,7 @@ describe( 'templates', () => {
await page.keyboard.press( 'Backspace' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down Expand Up @@ -103,6 +105,7 @@ describe( 'templates', () => {
await page.keyboard.press( 'Backspace' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ describe( 'WP Editor Meta Boxes', () => {
await publishPost();

await page.reload();
await page.waitForSelector( '.edit-post-layout' );

await expect( page ).toClick( '#test_tinymce_id-html' );
await page.waitForSelector( '#test_tinymce_id' );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ describe( 'adding blocks', () => {
it( 'Should insert content using the placeholder and the regular inserter', async () => {
// This ensures the editor is loaded in navigation mode.
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Set a tall viewport. The typewriter's intrinsic height can be enough
// to scroll the page on a shorter viewport, thus obscuring the presence
Expand Down
3 changes: 3 additions & 0 deletions packages/e2e-tests/specs/editor/various/autosave.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ describe( 'autosave', () => {
);
// Reload without saving on the server
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

const notice = await page.$eval(
'.components-notice__content',
Expand Down Expand Up @@ -192,6 +193,7 @@ describe( 'autosave', () => {
).toBe( 1 );

await page.reload();
await page.waitForSelector( '.edit-post-layout' );
const notice = await page.$eval(
'.components-notice__content',
( element ) => element.innerText
Expand Down Expand Up @@ -329,6 +331,7 @@ describe( 'autosave', () => {
).toBe( 1 );

await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// FIXME: Occasionally, upon reload, there is no server-provided
// autosave value available, despite our having previously explicitly
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ describe( 'Change detection', () => {
try {
page.on( 'dialog', handleOnDialog );
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Ensure whether it was expected that dialog was encountered.
expect( hadDialog ).toBe( isDirty );
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/specs/editor/various/new-post.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ describe( 'new editor state', () => {
await page.waitForSelector( '.editor-post-saved-state.is-saved' );
// Reload the browser so a post is loaded with a title.
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

const activeElementClasses = await page.evaluate( () => {
return Object.values( document.activeElement.classList );
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-tests/specs/editor/various/nux.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ describe( 'New User Experience (NUX)', () => {

// Reload the editor
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Guide should be closed
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
Expand All @@ -108,6 +109,7 @@ describe( 'New User Experience (NUX)', () => {

// Reload the editor
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Guide should be closed
welcomeGuide = await page.$( '.edit-post-welcome-guide' );
Expand Down
2 changes: 2 additions & 0 deletions packages/e2e-tests/specs/editor/various/preferences.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ describe( 'preferences', () => {
// See: https://github.com/WordPress/gutenberg/issues/6377
// See: https://github.com/WordPress/gutenberg/pull/8995
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
expect( await getActiveSidebarTabText() ).toBe( 'Document' );

// Dismiss
Expand All @@ -51,6 +52,7 @@ describe( 'preferences', () => {

// Remember after reload.
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
expect( await getActiveSidebarTabText() ).toBe( null );
} );
} );
3 changes: 3 additions & 0 deletions packages/e2e-tests/specs/editor/various/undo.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ describe( 'undo', () => {
await page.keyboard.type( 'test' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );
await page.click( '[data-type="core/paragraph"]' );
await pressKeyWithModifier( 'primary', 'a' );
await pressKeyWithModifier( 'primary', 'b' );
Expand Down Expand Up @@ -345,6 +346,7 @@ describe( 'undo', () => {
await page.keyboard.type( 'original' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Issue is demonstrated by forcing state merges (multiple inputs) on
// an existing text after a fresh reload.
Expand Down Expand Up @@ -391,6 +393,7 @@ describe( 'undo', () => {
await page.keyboard.type( '1' );
await saveDraft();
await page.reload();
await page.waitForSelector( '.edit-post-layout' );

// Expect undo button to be disabled.
expect(
Expand Down
1 change: 1 addition & 0 deletions packages/e2e-tests/specs/performance/performance.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ describe( 'Performance', () => {
}

// Measuring typing performance
await page.waitForSelector( '.edit-post-layout' );
await insertBlock( 'Paragraph' );
i = 200;
const traceFile = __dirname + '/trace.json';
Expand Down

0 comments on commit dc2c833

Please sign in to comment.