Skip to content

Commit

Permalink
Add end 2 end test
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Oct 8, 2018
1 parent 22a1c81 commit 531e34b
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/e2e/specs/preview.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
newPost,
getUrl,
publishPost,
saveDraft,
} from '../support/utils';

describe( 'Preview', () => {
Expand Down Expand Up @@ -137,4 +138,41 @@ describe( 'Preview', () => {

await previewPage.close();
} );

it( 'Should not revert title during a preview right after a save draft', async () => {
const editorPage = page;

// Type aaaaa in the title filed.
await editorPage.type( '.editor-post-title__input', 'aaaaa' );
await editorPage.keyboard.press( 'Tab' );

// Save the post as a draft.
await editorPage.waitForSelector( '.editor-post-save-draft' );
await saveDraft();

// Open the preview page.
const previewPage = await openPreviewPage( editorPage );

// Title in preview should match input.
let previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
expect( previewTitle ).toBe( 'aaaaa' );

// Return to editor.
await editorPage.bringToFront();

// Append bbbbb to the title, and tab away from the title so blur event is triggered.
await editorPage.type( '.editor-post-title__input', 'bbbbb' );
await editorPage.keyboard.press( 'Tab' );

// Save draft and open the preview page right after.
await editorPage.waitForSelector( '.editor-post-save-draft' );
await saveDraft();
await waitForPreviewNavigation( previewPage );

// Title in preview should match updated input.
previewTitle = await previewPage.$eval( '.entry-title', ( node ) => node.textContent );
expect( previewTitle ).toBe( 'aaaaabbbbb' );

await previewPage.close();
} );
} );

0 comments on commit 531e34b

Please sign in to comment.