Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NUX E2E tests #7165

Merged
merged 1 commit into from
Jun 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions test/e2e/specs/nux.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/**
* Internal dependencies
*/
import '../support/bootstrap';
import { newDesktopBrowserPage, newPost } from '../support/utils';

describe( 'NUX', () => {
it( 'should show tips to a first-time user', async () => {
await newDesktopBrowserPage();
await newPost( undefined, false );

const firstTipText = await page.$eval( '.nux-dot-tip', ( element ) => element.innerText );
expect( firstTipText ).toContain( 'Welcome to the wonderful world of blocks!' );

const [ nextTipButton ] = await page.$x( '//button[contains(text(), \'See next tip\')]' );
await nextTipButton.click();

const secondTipText = await page.$eval( '.nux-dot-tip', ( element ) => element.innerText );
expect( secondTipText ).toContain( 'You’ll find more settings for your page and blocks in the sidebar.' );
} );
} );
12 changes: 7 additions & 5 deletions test/e2e/support/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,15 @@ export async function visitAdmin( adminPath, query ) {
}
}

export async function newPost( postType ) {
export async function newPost( postType, disableTips = true ) {
await visitAdmin( 'post-new.php', postType ? 'post_type=' + postType : '' );

// Disable new user tips so that their UI doesn't get in the way
await page.evaluate( () => {
wp.data.dispatch( 'core/nux' ).disableTips();
} );
if ( disableTips ) {
// Disable new user tips so that their UI doesn't get in the way
await page.evaluate( () => {
wp.data.dispatch( 'core/nux' ).disableTips();
} );
}
}

export async function newDesktopBrowserPage() {
Expand Down