mirror of
https://gh.wpcy.net/https://github.com/WordPress/create-block-theme.git
synced 2026-05-28 04:23:07 +08:00
Some checks failed
Run checks / Lint (push) Failing after -8h1m22s
Run checks / Compute previous WordPress version (push) Successful in -8h1m22s
Run checks / PHP 7.4 (push) Failing after -8h1m22s
Run checks / PHP 7.4 (WP previous major version) (push) Failing after -8h1m22s
Run checks / PHP 8.0 (push) Failing after -8h1m22s
Run checks / PHP 8.0 (WP previous major version) (push) Failing after -8h1m22s
Run checks / PHP 8.1 (push) Failing after -8h1m22s
Run checks / PHP 8.1 (WP previous major version) (push) Failing after -8h1m22s
Run checks / E2E Tests (push) Failing after 7s
Run checks / PHP 8.2 (push) Failing after -8h1m22s
Run checks / PHP 8.2 (WP previous major version) (push) Failing after -8h1m22s
Run checks / PHP 8.3 (WP previous major version) (push) Failing after -8h1m22s
Run checks / PHP 8.3 (push) Failing after 5s
* Add e2e tests
* Add e2e tests to CI
* Fix lint errors
* Use psge.once()
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
* Remove unnecessary test
* Attempt to fix linting error
* Remove last()
* Delete test theme in afterAll
* Add @playwright/test
* Also delete the theme in the beforeAll step
* Test the theme was activated
* Also test opening the plugin sidebar
* Attempt to fix landing-page timeout
* Test that zip file was downloaded
* Align test scripts closer to GB
* Update specs/landing-page.spec.js
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>
* Revert "Update specs/landing-page.spec.js"
This reverts commit b0e688fea0.
* Only run delete theme command if theme exists
---------
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Jerry Jones <jones.jeremydavid@gmail.com>
112 lines
3 KiB
JavaScript
112 lines
3 KiB
JavaScript
/**
|
|
* External dependencies
|
|
*/
|
|
const { execSync } = require( 'child_process' );
|
|
|
|
/**
|
|
* WordPress dependencies
|
|
*/
|
|
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );
|
|
|
|
const E2E_THEME_SLUG = 'e2e-test-theme';
|
|
|
|
test.describe( 'Create Block Theme — Admin Landing Page', () => {
|
|
let originalThemeSlug;
|
|
|
|
test.beforeAll( async ( { requestUtils } ) => {
|
|
const themes = await requestUtils.rest( { path: '/wp/v2/themes' } );
|
|
const active = themes.find( ( { status } ) => status === 'active' );
|
|
originalThemeSlug = active?.stylesheet;
|
|
|
|
if (
|
|
themes.some( ( { stylesheet } ) => stylesheet === E2E_THEME_SLUG )
|
|
) {
|
|
execSync(
|
|
`npx wp-env run tests-cli wp theme delete ${ E2E_THEME_SLUG }`,
|
|
{ stdio: 'ignore' }
|
|
);
|
|
}
|
|
} );
|
|
|
|
test.afterAll( async ( { requestUtils } ) => {
|
|
if ( originalThemeSlug ) {
|
|
await requestUtils.activateTheme( originalThemeSlug );
|
|
}
|
|
|
|
const themes = await requestUtils.rest( { path: '/wp/v2/themes' } );
|
|
if (
|
|
themes.some( ( { stylesheet } ) => stylesheet === E2E_THEME_SLUG )
|
|
) {
|
|
execSync(
|
|
`npx wp-env run tests-cli wp theme delete ${ E2E_THEME_SLUG }`,
|
|
{ stdio: 'ignore' }
|
|
);
|
|
}
|
|
} );
|
|
|
|
test( 'page loads and shows main heading', async ( { admin, page } ) => {
|
|
await admin.visitAdminPage(
|
|
'themes.php',
|
|
'page=create-block-theme-landing'
|
|
);
|
|
await expect(
|
|
page.getByRole( 'heading', { name: 'What would you like to do?' } )
|
|
).toBeVisible();
|
|
} );
|
|
|
|
test( 'clicking export downloads a zip file', async ( { admin, page } ) => {
|
|
await admin.visitAdminPage(
|
|
'themes.php',
|
|
'page=create-block-theme-landing'
|
|
);
|
|
const [ download ] = await Promise.all( [
|
|
page.waitForEvent( 'download' ),
|
|
page.getByRole( 'button', { name: /Export/ } ).click(),
|
|
] );
|
|
expect( download.suggestedFilename() ).toMatch( /\.zip$/ );
|
|
} );
|
|
|
|
test( 'create blank theme modal opens with name field', async ( {
|
|
admin,
|
|
page,
|
|
} ) => {
|
|
await admin.visitAdminPage(
|
|
'themes.php',
|
|
'page=create-block-theme-landing'
|
|
);
|
|
await page
|
|
.getByRole( 'button', { name: /Create a new Blank Theme/i } )
|
|
.click();
|
|
await expect( page.getByLabel( /Theme name/i ) ).toBeVisible();
|
|
} );
|
|
|
|
test( 'create blank theme end-to-end', async ( {
|
|
admin,
|
|
page,
|
|
requestUtils,
|
|
} ) => {
|
|
await admin.visitAdminPage(
|
|
'themes.php',
|
|
'page=create-block-theme-landing'
|
|
);
|
|
|
|
// Accept the alert dialog that fires on successful theme creation.
|
|
page.once( 'dialog', ( dialog ) => dialog.accept() );
|
|
|
|
await page
|
|
.getByRole( 'button', { name: /Create a new Blank Theme/i } )
|
|
.click();
|
|
await page.getByLabel( /Theme name/i ).fill( 'E2E Test Theme' );
|
|
await page
|
|
.getByRole( 'button', {
|
|
name: 'Create and Activate Blank Theme',
|
|
} )
|
|
.click();
|
|
|
|
await page.waitForURL( /site-editor/, { waitUntil: 'commit' } );
|
|
|
|
const themes = await requestUtils.rest( { path: '/wp/v2/themes' } );
|
|
const active = themes.find( ( { status } ) => status === 'active' );
|
|
expect( active?.stylesheet ).toBe( E2E_THEME_SLUG );
|
|
} );
|
|
} );
|