-
Notifications
You must be signed in to change notification settings - Fork 48
E2E tests #220
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
+176
−13
Merged
E2E tests #220
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
4a93177
Unify test command naming with wordpress-develop test commands
JanJakes 5502d1e
Run WordPress E2E tests with SQLite
JanJakes 8f7f203
Automatically set up test environment, improve config
JanJakes c37f76d
Setup SQLite driver E2E tests and add an E2E test for Query Monitor
JanJakes 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
There are no files selected for viewing
This file contains hidden or 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,35 @@ | ||
name: End-to-end Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: End-to-end Tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set UID and GID for PHP in WordPress images | ||
run: | | ||
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV | ||
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV | ||
|
||
- name: Install Playwright browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run end-to-end tests | ||
run: composer run test-e2e | ||
|
||
- name: Stop Docker containers | ||
if: always() | ||
run: composer run wp-test-clean |
This file contains hidden or 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,35 @@ | ||
name: WordPress End-to-end Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
test: | ||
name: WordPress End-to-end Tests | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 20 | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Set UID and GID for PHP in WordPress images | ||
run: | | ||
echo "PHP_FPM_UID=$(id -u)" >> $GITHUB_ENV | ||
echo "PHP_FPM_GID=$(id -g)" >> $GITHUB_ENV | ||
|
||
- name: Install Playwright browsers | ||
run: npx playwright install --with-deps | ||
|
||
- name: Run WordPress end-to-end tests | ||
run: composer run wp-test-e2e | ||
|
||
- name: Stop Docker containers | ||
if: always() | ||
run: composer run wp-test-clean |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,3 @@ | ||
/artifacts | ||
/node_modules | ||
/package.json |
This file contains hidden or 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,27 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import path from 'node:path'; | ||
import { defineConfig } from '@playwright/test'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
const baseConfig = require( '@wordpress/scripts/config/playwright.config' ); | ||
|
||
process.env.WP_ARTIFACTS_PATH ??= path.join( process.cwd(), 'artifacts' ); | ||
process.env.STORAGE_STATE_PATH ??= path.join( | ||
process.env.WP_ARTIFACTS_PATH, | ||
'storage-states/admin.json' | ||
); | ||
|
||
const config = defineConfig( { | ||
...baseConfig, | ||
globalSetup: require.resolve( '../../wordpress/tests/e2e/config/global-setup.js' ), | ||
webServer: { | ||
...baseConfig.webServer, | ||
command: 'npm run env:start', | ||
}, | ||
} ); | ||
|
||
export default config; |
This file contains hidden or 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,47 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { test, expect } from '@wordpress/e2e-test-utils-playwright'; | ||
|
||
test.describe( 'Query Monitor plugin', () => { | ||
async function deactivateQueryMonitor( requestUtils ) { | ||
await requestUtils.deactivatePlugin( 'query-monitor' ); | ||
const plugin = await requestUtils.rest( { | ||
path: 'wp/v2/plugins/query-monitor/query-monitor', | ||
} ); | ||
expect( plugin.status ).toBe( 'inactive' ); | ||
} | ||
|
||
test.beforeEach( async ( { requestUtils }) => { | ||
await deactivateQueryMonitor( requestUtils ); | ||
} ); | ||
|
||
test.afterEach( async ( { requestUtils }) => { | ||
await deactivateQueryMonitor( requestUtils ); | ||
} ); | ||
|
||
test( 'should activate', async ( { admin, page } ) => { | ||
// Activate the Query Monitor plugin on the plugins page. | ||
await admin.visitAdminPage( '/plugins.php' ); | ||
await page.getByLabel( 'Activate Query Monitor', { exact: true } ).click(); | ||
await page.getByText( 'Plugin activated.', { exact: true } ).waitFor(); | ||
|
||
// Click on the Query Monitor menu item in the WordPress admin bar. | ||
await page.locator('a[role="menuitem"][href="#qm-overview"][aria-expanded="false"]').click(); | ||
|
||
// Wait for the Query Monitor panel to open. | ||
await page.locator( '#query-monitor-main' ).waitFor(); | ||
await page.getByRole( 'heading', { name: 'Query Monitor', exact: true } ).waitFor(); | ||
|
||
// Click on the Database Queries tab. | ||
await page.getByRole( 'tab', { name: 'Database Queries' } ).click(); | ||
|
||
// Verify the first logged query. | ||
const sqlCell = page.locator( '.qm-row-sql' ).first(); | ||
await expect( sqlCell ).toContainText( 'SELECT option_name, option_value' ); | ||
|
||
// Check that the query is logged with SQLite information. | ||
await sqlCell.getByLabel( 'Toggle SQLite queries' ).click(); | ||
expect( page.locator('.qm-sqlite-query', { hasText: 'SELECT `option_name` , `option_value` FROM `wp_options`' }).first() ).toBeVisible(); | ||
} ); | ||
} ); |
This file contains hidden or 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
Oops, something went wrong.
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.
It would be useful to run this both with wp-env and Playground CLI. Not a blocker here
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.
@adamziel Should we do that here or in the Playground repo? I guess if what you mean is using Playground CLI for any tests that we write for the SQLite repo, then it probably belongs to the SQLite repo; just making sure. I can create a ticket for that.