Test Gutenberg and its nightly build
This commit is contained in:
parent
a5c3838a1d
commit
074c8b871a
|
@ -203,9 +203,9 @@ jobs:
|
|||
# - plugin: 'WooCommerce Subscriptions'
|
||||
# repo: WC_SUBSCRIPTIONS_REPO
|
||||
# private: true
|
||||
- plugin: 'Gutenberg' # latest stable
|
||||
- plugin: 'Gutenberg'
|
||||
repo: 'WordPress/gutenberg'
|
||||
- plugin: 'Gutenberg' # nightly
|
||||
- plugin: 'Gutenberg - Nightly'
|
||||
repo: 'bph/gutenberg'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
|
|
@ -15,9 +15,18 @@ const {
|
|||
} = require( '../../utils/plugin-utils' );
|
||||
|
||||
const skipMessage = 'Skipping this test because PLUGIN_REPOSITORY is undefined';
|
||||
const pluginSlug = path.basename( PLUGIN_REPOSITORY );
|
||||
const deletePluginFromSite = async ( { request, baseURL } ) => {
|
||||
await deletePlugin( {
|
||||
request,
|
||||
baseURL,
|
||||
slug: pluginSlug,
|
||||
username: admin.username,
|
||||
password: admin.password,
|
||||
} );
|
||||
};
|
||||
|
||||
let pluginPath;
|
||||
let pluginSlug;
|
||||
|
||||
test.skip( () => {
|
||||
const shouldSkip = ! PLUGIN_REPOSITORY;
|
||||
|
@ -33,8 +42,6 @@ test.describe( `${ PLUGIN_NAME } plugin can be uploaded and activated`, () => {
|
|||
test.use( { storageState: ADMINSTATE } );
|
||||
|
||||
test.beforeAll( async ( { playwright, baseURL } ) => {
|
||||
pluginSlug = path.basename( PLUGIN_REPOSITORY );
|
||||
|
||||
pluginPath = await test.step(
|
||||
`Download ${ PLUGIN_NAME } plugin zip`,
|
||||
async () => {
|
||||
|
@ -45,41 +52,76 @@ test.describe( `${ PLUGIN_NAME } plugin can be uploaded and activated`, () => {
|
|||
}
|
||||
);
|
||||
|
||||
// Delete plugin from test site if it's installed.
|
||||
await test.step(
|
||||
"Delete plugin from test site if it's installed.",
|
||||
async () => {
|
||||
await deletePlugin( {
|
||||
await deletePluginFromSite( {
|
||||
request: playwright.request,
|
||||
baseURL,
|
||||
slug: pluginSlug,
|
||||
username: admin.username,
|
||||
password: admin.password,
|
||||
} );
|
||||
}
|
||||
);
|
||||
} );
|
||||
|
||||
test.afterAll( async ( {} ) => {
|
||||
// Delete the downloaded zip.
|
||||
await deleteZip( pluginPath );
|
||||
test.afterAll( async ( { playwright, baseURL } ) => {
|
||||
await test.step(
|
||||
"Delete plugin from test site if it's installed.",
|
||||
async () => {
|
||||
await deletePluginFromSite( {
|
||||
request: playwright.request,
|
||||
baseURL,
|
||||
} );
|
||||
}
|
||||
);
|
||||
|
||||
await test.step( 'Delete the downloaded zip', async () => {
|
||||
await deleteZip( pluginPath );
|
||||
} );
|
||||
} );
|
||||
|
||||
test( `can upload and activate ${ PLUGIN_NAME }`, async ( { page } ) => {
|
||||
await installPluginThruWpCli( pluginPath );
|
||||
test( `can upload and activate "${ PLUGIN_NAME }"`, async ( { page } ) => {
|
||||
await test.step(
|
||||
`Install "${ PLUGIN_NAME }" through WP CLI`,
|
||||
async () => {
|
||||
await installPluginThruWpCli( pluginPath );
|
||||
}
|
||||
);
|
||||
|
||||
// Go to 'Installed plugins' page.
|
||||
// Repeat in case the newly installed plugin redirects to their own onboarding screen upon first install, like what Yoast SEO does.
|
||||
let reload = 2;
|
||||
do {
|
||||
await page.goto( 'wp-admin/plugins.php', {
|
||||
waitUntil: 'networkidle',
|
||||
await test.step( 'Go to the "Installed Plugins" page', async () => {
|
||||
await page.goto( 'wp-admin/plugins.php' );
|
||||
} );
|
||||
|
||||
await test.step(
|
||||
`Expect "${ PLUGIN_NAME }" to be listed and active.`,
|
||||
async () => {
|
||||
await expect(
|
||||
page.locator( `#deactivate-${ pluginSlug }` )
|
||||
).toBeVisible();
|
||||
}
|
||||
);
|
||||
|
||||
await test.step( 'Expect the shop to load successfully.', async () => {
|
||||
const shopHeading = page.getByRole( 'heading', {
|
||||
name: 'Shop',
|
||||
} );
|
||||
} while ( ! page.url().includes( '/plugins.php' ) && --reload );
|
||||
|
||||
// Assert that the plugin is listed and active
|
||||
await expect(
|
||||
page.locator( `#deactivate-${ pluginSlug }` )
|
||||
).toBeVisible();
|
||||
await page.goto( '/shop' );
|
||||
await expect( shopHeading ).toBeVisible();
|
||||
} );
|
||||
|
||||
await test.step(
|
||||
'Expect the WooCommerce Homepage to load successfully.',
|
||||
async () => {
|
||||
const statsOverviewHeading = page.getByText( 'Stats overview' );
|
||||
const skipSetupStoreLink = page.getByRole( 'button', {
|
||||
name: 'Skip setup store details',
|
||||
} );
|
||||
|
||||
await page.goto( '/wp-admin/admin.php?page=wc-admin' );
|
||||
await expect(
|
||||
statsOverviewHeading.or( skipSetupStoreLink )
|
||||
).toBeVisible();
|
||||
}
|
||||
);
|
||||
} );
|
||||
} );
|
||||
|
|
|
@ -38,6 +38,7 @@ export const deletePlugin = async ( {
|
|||
baseURL,
|
||||
extraHTTPHeaders: {
|
||||
Authorization: `Basic ${ encodeCredentials( username, password ) }`,
|
||||
cookie: '',
|
||||
},
|
||||
} );
|
||||
const listPluginsResponse = await apiContext.get(
|
||||
|
@ -55,37 +56,12 @@ export const deletePlugin = async ( {
|
|||
if ( pluginToDelete ) {
|
||||
const { plugin } = pluginToDelete;
|
||||
const requestURL = `/wp-json/wp/v2/plugins/${ plugin }`;
|
||||
let response;
|
||||
|
||||
// Some plugins do not respond to some of the WP REST API endpoints like Contact Form 7.
|
||||
// Print warning in such cases.
|
||||
const warn = async ( response, warningMsg ) => {
|
||||
console.warn( warningMsg );
|
||||
console.warn(
|
||||
`Response status: ${ response.status() } ${ response.statusText() }`
|
||||
);
|
||||
console.warn( `Response body:` );
|
||||
console.warn( await response.json() );
|
||||
console.warn( '\n' );
|
||||
};
|
||||
|
||||
response = await apiContext.put( requestURL, {
|
||||
await apiContext.put( requestURL, {
|
||||
data: { status: 'inactive' },
|
||||
} );
|
||||
if ( ! response.ok() ) {
|
||||
await warn(
|
||||
response,
|
||||
`WARNING: Failed to deactivate plugin ${ plugin }`
|
||||
);
|
||||
}
|
||||
|
||||
response = await apiContext.delete( requestURL );
|
||||
if ( ! response.ok() ) {
|
||||
await warn(
|
||||
response,
|
||||
`WARNING: Failed to delete plugin ${ plugin }`
|
||||
);
|
||||
}
|
||||
await apiContext.delete( requestURL );
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -164,10 +140,8 @@ export const downloadZip = async ( {
|
|||
* @param {string} zipFilePath Local file path to the ZIP.
|
||||
*/
|
||||
export const deleteZip = async ( zipFilePath ) => {
|
||||
console.log( `Deleting file located in ${ zipFilePath }...` );
|
||||
await fs.unlink( zipFilePath, ( err ) => {
|
||||
if ( err ) throw err;
|
||||
console.log( `Successfully deleted!` );
|
||||
} );
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue