forked from woocommerce/woocommerce
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request woocommerce#33139 from woocommerce/e2e/rep-playwri…
…ght-feature-flag Run Playwright tests behind feature flag
- Loading branch information
Showing
41 changed files
with
4,126 additions
and
27 deletions.
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
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 |
---|---|---|
@@ -1,6 +1,2 @@ | ||
# Collection output | ||
collection.json | ||
|
||
# Allure directories | ||
allure-report | ||
allure-results |
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
2 changes: 2 additions & 0 deletions
2
plugins/woocommerce/changelog/e2e-rep-playwright-feature-flag
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,2 @@ | ||
Significance: patch | ||
Type: dev |
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,58 @@ | ||
const { chromium } = require( '@playwright/test' ); | ||
const fs = require( 'fs' ); | ||
|
||
module.exports = async ( config ) => { | ||
// Clear out the previous save states | ||
const adminState = 'e2e/storage/adminState.json'; | ||
const customerState = 'e2e/storage/customerState.json'; | ||
fs.unlink( adminState, function ( err ) { | ||
if ( err ) { | ||
// File doesn't exist yet, so will just create it. | ||
} else { | ||
// File exists. Delete it so it can be re-created. | ||
} | ||
} ); | ||
fs.unlink( customerState, function ( err ) { | ||
if ( err ) { | ||
// File doesn't exist yet, so will just create it. | ||
} else { | ||
// File exists. Delete it so it can be re-created. | ||
} | ||
} ); | ||
|
||
const { baseURL } = config.projects[ 0 ].use; | ||
// Sign in as admin user and save state | ||
const browser = await chromium.launch(); | ||
const adminPage = await browser.newPage(); | ||
await adminPage.goto( `${ baseURL }/wp-admin` ); | ||
await adminPage.fill( 'input[name="log"]', 'admin' ); | ||
await adminPage.fill( 'input[name="pwd"]', 'password' ); | ||
await adminPage.click( 'text=Log In' ); | ||
await adminPage | ||
.context() | ||
.storageState( { path: 'e2e/storage/adminState.json' } ); | ||
// While we're here, let's add a consumer token for API access | ||
await adminPage.goto( | ||
`${ baseURL }/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys&create-key=1` | ||
); | ||
await adminPage.fill( '#key_description', 'Key for API access' ); | ||
await adminPage.selectOption( '#key_permissions', 'read_write' ); | ||
await adminPage.click( 'text=Generate API key' ); | ||
process.env.CONSUMER_KEY = await adminPage.inputValue( | ||
'#key_consumer_key' | ||
); | ||
process.env.CONSUMER_SECRET = await adminPage.inputValue( | ||
'#key_consumer_secret' | ||
); | ||
|
||
// Sign in as customer user and save state | ||
const customerPage = await browser.newPage(); | ||
await customerPage.goto( `${ baseURL }/wp-admin` ); | ||
await customerPage.fill( 'input[name="log"]', 'customer' ); | ||
await customerPage.fill( 'input[name="pwd"]', 'password' ); | ||
await customerPage.click( 'text=Log In' ); | ||
await customerPage | ||
.context() | ||
.storageState( { path: 'e2e/storage/customerState.json' } ); | ||
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,16 @@ | ||
const { chromium } = require( '@playwright/test' ); | ||
|
||
module.exports = async ( config ) => { | ||
const { baseURL } = config.projects[ 0 ].use; | ||
// Clean up the consumer keys | ||
const browser = await chromium.launch(); | ||
const adminPage = await browser.newPage(); | ||
await adminPage.goto( `${ baseURL }/wp-admin` ); | ||
await adminPage.fill( 'input[name="log"]', 'admin' ); | ||
await adminPage.fill( 'input[name="pwd"]', 'password' ); | ||
await adminPage.click( 'text=Log In' ); | ||
await adminPage.goto( | ||
`${ baseURL }/wp-admin/admin.php?page=wc-settings&tab=advanced§ion=keys` | ||
); | ||
await adminPage.dispatchEvent( 'a.submitdelete', 'click' ); | ||
}; |
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,38 @@ | ||
const { devices } = require( '@playwright/test' ); | ||
|
||
const config = { | ||
timeout: 20000, | ||
outputDir: './report', | ||
globalSetup: require.resolve( './global-setup' ), | ||
globalTeardown: require.resolve( './global-teardown' ), | ||
testDir: 'tests', | ||
retries: 1, | ||
reporter: [ | ||
[ 'list' ], | ||
[ 'html', { outputFolder: 'output' } ], | ||
[ 'allure-playwright', { outputFolder: 'e2e/allure-results' } ], | ||
], | ||
use: { | ||
screenshot: 'only-on-failure', | ||
video: 'on-first-retry', | ||
trace: 'retain-on-failure', | ||
viewport: { width: 1280, height: 720 }, | ||
baseURL: 'http://localhost:8086', | ||
}, | ||
projects: [ | ||
{ | ||
name: 'Chrome', | ||
use: { ...devices[ 'Desktop Chrome' ] }, | ||
}, | ||
// { | ||
// name: 'Firefox', | ||
// use: { ...devices['Desktop Firefox'] }, | ||
// }, | ||
// { | ||
// name: 'Webkit', | ||
// use: { ...devices['Desktop Webkit'] }, | ||
// }, | ||
], | ||
}; | ||
|
||
module.exports = config; |
Oops, something went wrong.