From 263c5ace7e7cb4b79c80dae18e58c6e5dc788a71 Mon Sep 17 00:00:00 2001 From: Nik Tsekouras Date: Fri, 23 Oct 2020 14:51:47 +0300 Subject: [PATCH] Fix autosave e2e tests (#26416) --- .../specs/editor/various/autosave.test.js | 72 +++++++++---------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/packages/e2e-tests/specs/editor/various/autosave.test.js b/packages/e2e-tests/specs/editor/various/autosave.test.js index ef0522dc9d990e..6608b286980bac 100644 --- a/packages/e2e-tests/specs/editor/various/autosave.test.js +++ b/packages/e2e-tests/specs/editor/various/autosave.test.js @@ -124,42 +124,6 @@ describe( 'autosave', () => { ); } ); - it( 'should clear sessionStorage upon user logout', async () => { - await clickBlockAppender(); - await page.keyboard.type( 'before save' ); - await saveDraft(); - - // Fake local autosave - await page.evaluate( - ( postId ) => - window.sessionStorage.setItem( - `wp-autosave-block-editor-post-${ postId }`, - JSON.stringify( { - post_title: 'A', - content: 'B', - excerpt: 'C', - } ) - ), - await getCurrentPostId() - ); - expect( - await page.evaluate( () => window.sessionStorage.length ) - ).toBe( 1 ); - - await Promise.all( [ - page.waitForSelector( '#wp-admin-bar-logout', { visible: true } ), - page.hover( '#wp-admin-bar-my-account' ), - ] ); - await Promise.all( [ - page.waitForNavigation(), - page.click( '#wp-admin-bar-logout' ), - ] ); - - expect( - await page.evaluate( () => window.sessionStorage.length ) - ).toBe( 0 ); - } ); - it( "shouldn't contaminate other posts", async () => { await clickBlockAppender(); await page.keyboard.type( 'before save' ); @@ -338,6 +302,42 @@ describe( 'autosave', () => { expect( notice ).toContain( AUTOSAVE_NOTICE_REMOTE ); } ); + it( 'should clear sessionStorage upon user logout', async () => { + await clickBlockAppender(); + await page.keyboard.type( 'before save' ); + await saveDraft(); + + // Fake local autosave + await page.evaluate( + ( postId ) => + window.sessionStorage.setItem( + `wp-autosave-block-editor-post-${ postId }`, + JSON.stringify( { + post_title: 'A', + content: 'B', + excerpt: 'C', + } ) + ), + await getCurrentPostId() + ); + expect( + await page.evaluate( () => window.sessionStorage.length ) + ).toBe( 1 ); + + await Promise.all( [ + page.waitForSelector( '#wp-admin-bar-logout', { visible: true } ), + page.hover( '#wp-admin-bar-my-account' ), + ] ); + await Promise.all( [ + page.waitForNavigation(), + page.click( '#wp-admin-bar-logout' ), + ] ); + + expect( + await page.evaluate( () => window.sessionStorage.length ) + ).toBe( 0 ); + } ); + afterEach( async () => { toggleOfflineMode( false ); await clearSessionStorage();