-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Testing: Experiment with Puppeteer for E2E testing #5618
Merged
Merged
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
b132e0d
Testing: Try puppeteer for E2E testing
aduth e7300e0
E2E tests: move the hello gutenberg cypress test
youknowriad 85c9b8e
E2E tests: Adding blocks test moved to puppeteer
youknowriad 4847a53
Add multi-selection test
youknowriad c4ad0c7
Adding the managing links test
youknowriad 327ef3d
Replace cypress with jest puppeteer
youknowriad db19420
Remove useless eslint configs
youknowriad 2453c0f
Removing useless comments
youknowriad 60910bc
Using snapshots for adding blocks tests
youknowriad 24f2d1a
update Puppeteer to 1.2.0
youknowriad 67813ee
Increase Jest Timeout for slow CI environments
youknowriad e35fbfa
More stable tests by increasing timeouts and launching a new page on …
youknowriad 2045979
Try treating the timeout as a successful navigation
youknowriad c829405
Tools: Use Eslint overrides for e2e tests
gziolo 397d36e
Tools: Use Eslint overrides for e2e tests
gziolo d9acccf
Adding dependencies comment
youknowriad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
E2E tests: move the hello gutenberg cypress test
- Loading branch information
commit e7300e085a5fe0de26a6d4bfc9a1b4096a646974
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* eslint-env jest */ | ||
/* global page */ | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import './support/bootstrap'; | ||
import { newPost, visitAdmin } from './support'; | ||
|
||
// Tests | ||
describe( 'hello', () => { | ||
beforeAll( async () => { | ||
await newPost(); | ||
} ); | ||
|
||
it( 'Should show the New Post Page in Gutenberg', async () => { | ||
expect( page.url() ).toEqual( expect.stringContaining( 'post-new.php' ) ); | ||
const title = await page.$( '[placeholder="Add title"]' ); | ||
expect( title ).not.toBeNull(); | ||
} ); | ||
|
||
it( 'Should have no history', async () => { | ||
const undoButton = await page.$( '.editor-history__undo:not( :disabled )' ); | ||
const redoButton = await page.$( '.editor-history__redo:not( :disabled )' ); | ||
|
||
expect( undoButton ).toBeNull(); | ||
expect( redoButton ).toBeNull(); | ||
} ); | ||
|
||
it( 'Should not prompt to confirm unsaved changes', async () => { | ||
await visitAdmin( 'edit.php' ); | ||
expect( page.url() ).not.toEqual( expect.stringContaining( 'post-new.php' ) ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* eslint-env jest */ | ||
/* global browser */ | ||
import puppeteer from 'puppeteer'; | ||
|
||
beforeAll( async () => { | ||
global.browser = await puppeteer.launch( { headless: false } ); | ||
global.page = await browser.newPage(); | ||
} ); | ||
|
||
afterAll( async () => { | ||
await browser.close(); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* global page */ | ||
import path from 'path'; | ||
import url from 'url'; | ||
|
||
// Config | ||
const BASE_URL = 'http:https://localhost:8888'; | ||
const USERNAME = 'admin'; | ||
const PASSWORD = 'password'; | ||
|
||
function getUrl( urlPath ) { | ||
return path.join( BASE_URL, urlPath ); | ||
} | ||
|
||
function getCurrentPathName() { | ||
return url.parse( page.url() ).pathname; | ||
} | ||
|
||
async function login() { | ||
if ( getCurrentPathName() !== '/wp-login.php' ) { | ||
await page.goto( getUrl( 'wp-login.php' ) ); | ||
} | ||
|
||
await page.type( '#user_login', USERNAME ); | ||
await page.type( '#user_pass', PASSWORD ); | ||
await page.click( '#wp-submit' ); | ||
return page.waitForNavigation(); | ||
} | ||
|
||
export async function visitAdmin( adminPath ) { | ||
await page.goto( path.join( BASE_URL, 'wp-admin', adminPath ) ); | ||
if ( getCurrentPathName() === '/wp-login.php' ) { | ||
await login(); | ||
return visitAdmin( adminPath ); | ||
} | ||
} | ||
|
||
export async function newPost() { | ||
await visitAdmin( 'post-new.php' ); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know that these specific comments add much value.