Skip to content

Commit

Permalink
Refactor isEditedPostAutosaveable selector. (+2 squashed commits)
Browse files Browse the repository at this point in the history
Squashed commits:
[531e34b] Add end 2 end test
[22a1c81] Autosave: Fix: Autosave may destroy save incorrect post title
  • Loading branch information
jorgefilipecosta committed Nov 27, 2018
1 parent ef596ca commit 31c1a11
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 @@ -127,4 +128,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 31c1a11

Please sign in to comment.