Skip to content

Commit

Permalink
Testing: Leverage saveDraft for meta boxes save
Browse files Browse the repository at this point in the history
  • Loading branch information
aduth committed Mar 5, 2019
1 parent a9df08f commit d9a4482
Showing 1 changed file with 8 additions and 15 deletions.
23 changes: 8 additions & 15 deletions packages/e2e-tests/specs/plugins/meta-boxes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ import {
insertBlock,
openDocumentSettingsSidebar,
publishPost,
saveDraft,
} from '@wordpress/e2e-test-utils';

describe( 'Meta boxes', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-plugin-meta-box' );
} );

beforeEach( async () => {
await createNewPost();
} );

Expand All @@ -29,23 +33,14 @@ describe( 'Meta boxes', () => {
await page.type( '.editor-post-title__input', 'Hello Meta' );
expect( await page.$( '.editor-post-save-draft' ) ).not.toBe( null );

await Promise.all( [
// Transitions between three states "Saving..." -> "Saved" -> "Save
// Draft" (the button is always visible while meta are present).
page.waitForSelector( '.editor-post-saved-state.is-saving' ),
page.waitForSelector( '.editor-post-saved-state.is-saved' ),
page.waitForSelector( '.editor-post-save-draft' ),

// Keyboard shortcut Ctrl+S save.
page.keyboard.down( 'Meta' ),
page.keyboard.press( 'S' ),
page.keyboard.up( 'Meta' ),
] );
await saveDraft();

// After saving, affirm that the button returns to Save Draft.
await page.waitForSelector( '.editor-post-save-draft' );
} );

it( 'Should render dynamic blocks when the meta box uses the excerpt for front end rendering', async () => {
// Publish a post so there's something for the latest posts dynamic block to render.
await createNewPost();
await page.type( '.editor-post-title__input', 'A published post' );
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Hello there!' );
Expand All @@ -67,7 +62,6 @@ describe( 'Meta boxes', () => {
} );

it( 'Should render the excerpt in meta based on post content if no explicit excerpt exists', async () => {
await createNewPost();
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Excerpt from content.' );
await page.type( '.editor-post-title__input', 'A published post' );
Expand All @@ -91,7 +85,6 @@ describe( 'Meta boxes', () => {
} );

it( 'Should render the explicitly set excerpt in meta instead of the content based one', async () => {
await createNewPost();
await insertBlock( 'Paragraph' );
await page.keyboard.type( 'Excerpt from content.' );
await page.type( '.editor-post-title__input', 'A published post' );
Expand Down

0 comments on commit d9a4482

Please sign in to comment.