Skip to content

Commit

Permalink
Tests: Use explicit setViewport calls
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jul 31, 2018
1 parent 69126e1 commit 78825c0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions test/e2e/specs/sidebar-behaviour.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ describe( 'Publishing', () => {
afterEach( async () => {
await clearLocalStorage();
await page.goto( 'about:blank' );
await setViewport( 'large' );
} );

it( 'Should have sidebar visible at the start with document sidebar active on desktop', async () => {
Expand Down Expand Up @@ -40,7 +39,7 @@ describe( 'Publishing', () => {

it( 'Should have the sidebar closed by default on mobile', async () => {
await setViewport( 'small' );
await newPost( { viewport: 'small' } );
await newPost();
const sidebar = await page.$( SIDEBAR_SELECTOR );
expect( sidebar ).toBeNull();
} );
Expand All @@ -61,7 +60,8 @@ describe( 'Publishing', () => {

it( 'Should reopen sidebar the sidebar when resizing from mobile to desktop if the sidebar was closed automatically', async () => {
await setViewport( 'large' );
await newPost( { viewport: 'small' } );
await newPost();
await setViewport( 'small' );

const sidebarsMobile = await page.$$( SIDEBAR_SELECTOR );
expect( sidebarsMobile ).toHaveLength( 0 );
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/support/setup-test-framework.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
clearLocalStorage,
disablePageDialogAccept,
enablePageDialogAccept,
setViewport,
visitAdmin,
} from './utils';

Expand All @@ -22,6 +23,7 @@ const { PUPPETEER_TIMEOUT } = process.env;
jest.setTimeout( PUPPETEER_TIMEOUT || 100000 );

beforeAll( async () => {
await setViewport( 'large' );
enablePageDialogAccept();
} );

Expand Down
4 changes: 1 addition & 3 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,9 @@ export async function visitAdmin( adminPath, query ) {
}
}

export async function newPost( { postType, viewport = 'large', enableTips = false } = {} ) {
export async function newPost( { postType, enableTips = false } = {} ) {
await visitAdmin( 'post-new.php', postType ? 'post_type=' + postType : '' );

setViewport( viewport );

const tipsEnabled = await page.evaluate( () => wp.data.select( 'core/nux' ).areTipsEnabled() );
if ( tipsEnabled && ! enableTips ) {
// Disable new user tips so that their UI doesn't get in the way
Expand Down

0 comments on commit 78825c0

Please sign in to comment.