E2e/gutenberg latest nightly 0 (#38287)

This commit is contained in:
nigeljamesstevenson 2023-05-19 12:24:08 +01:00 committed by GitHub
commit c99d60647e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 114 additions and 89 deletions

View File

@ -200,15 +200,17 @@ jobs:
- plugin: 'WooCommerce Subscriptions'
repo: WC_SUBSCRIPTIONS_REPO
private: true
- plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo
repo: 'Yoast/wordpress-seo'
- plugin: 'Contact Form 7'
repo: 'takayukister/contact-form-7'
- plugin: 'Gutenberg'
repo: 'WordPress/gutenberg'
- plugin: 'Gutenberg - Nightly'
repo: 'bph/gutenberg'
steps:
- uses: actions/checkout@v3
- name: Setup WooCommerce Monorepo
uses: ./.github/actions/setup-woocommerce-monorepo
with:
build-filters: woocommerce
- name: Launch wp-env e2e environment
working-directory: plugins/woocommerce
@ -224,13 +226,13 @@ jobs:
PLUGIN_REPOSITORY: ${{ matrix.private && secrets[matrix.repo] || matrix.repo }}
PLUGIN_NAME: ${{ matrix.plugin }}
GITHUB_TOKEN: ${{ secrets.E2E_GH_TOKEN }}
run: pnpm exec playwright test --config=tests/e2e-pw/playwright.config.js upload-plugin.spec.js
run: pnpm test:e2e-pw upload-plugin.spec.js
- name: Run the rest of E2E tests
working-directory: plugins/woocommerce
env:
E2E_MAX_FAILURES: 15
run: pnpm exec playwright test --config=tests/e2e-pw/playwright.config.js
run: pnpm test:e2e-pw
- name: Generate E2E Test report.
if: success() || failure()
@ -321,36 +323,29 @@ jobs:
matrix:
include:
- plugin: 'WooCommerce Payments'
repo: 'automattic/woocommerce-payments'
slug: woocommerce-payments
- plugin: 'WooCommerce PayPal Payments'
repo: 'woocommerce/woocommerce-paypal-payments'
slug: woocommerce-paypal-payments
- plugin: 'WooCommerce Shipping & Tax'
repo: 'automattic/woocommerce-services'
- plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo
repo: 'Yoast/wordpress-seo'
- plugin: 'Contact Form 7'
repo: 'takayukister/contact-form-7'
slug: woocommerce-services
- plugin: 'WooCommerce Subscriptions'
slug: woocommerce-subscriptions
- plugin: 'Gutenberg'
slug: gutenberg
- plugin: 'Gutenberg - Nightly'
slug: gutenberg-nightly
steps:
- name: Download test report artifact
uses: actions/download-artifact@v3
with:
name: ${{ env.ARTIFACT }}
# TODO: Add step to post job summary
- name: Get slug
id: get-slug
uses: actions/github-script@v6
with:
result-encoding: string
script: return "${{ matrix.repo }}".split( '/' ).pop()
- name: Publish reports
run: |
gh workflow run publish-test-reports-daily-plugins.yml \
-f run_id=$RUN_ID \
-f artifact="${{ env.ARTIFACT }}" \
-f plugin="${{ matrix.plugin }}" \
-f slug="${{ steps.get-slug.outputs.result }}" \
-f slug="${{ matrix.slug }}" \
-f s3_root=public \
--repo woocommerce/woocommerce-test-reports

View File

@ -657,12 +657,12 @@ jobs:
repo: WC_SUBSCRIPTIONS_REPO
private: true
env_description: 'woocommerce-subscriptions'
- plugin: 'WordPress SEO' # Yoast SEO in the UI, but the slug is wordpress-seo
repo: 'Yoast/wordpress-seo'
env_description: 'wordpress-seo'
- plugin: 'Contact Form 7'
repo: 'takayukister/contact-form-7'
env_description: 'contact-form-7'
- plugin: 'Gutenberg'
repo: 'WordPress/gutenberg'
env_description: 'gutenberg'
- plugin: 'Gutenberg - Nightly'
repo: 'bph/gutenberg'
env_description: 'gutenberg-nightly'
steps:
- name: Checkout
uses: actions/checkout@v3

View File

@ -0,0 +1,4 @@
Significance: patch
Type: dev
Add Gutenberg nightly and latest stable into the daily and release smoke tests.

View File

@ -15,9 +15,17 @@ const {
} = require( '../../utils/plugin-utils' );
const skipMessage = 'Skipping this test because PLUGIN_REPOSITORY is undefined';
const deletePluginFromSite = async ( { request, baseURL } ) => {
await deletePlugin( {
request,
baseURL,
slug: pluginSlug,
username: admin.username,
password: admin.password,
} );
};
let pluginPath;
let pluginSlug;
let pluginSlug, pluginPath;
test.skip( () => {
const shouldSkip = ! PLUGIN_REPOSITORY;
@ -35,42 +43,86 @@ test.describe( `${ PLUGIN_NAME } plugin can be uploaded and activated`, () => {
test.beforeAll( async ( { playwright, baseURL } ) => {
pluginSlug = path.basename( PLUGIN_REPOSITORY );
// Download plugin.
pluginPath = await downloadZip( {
repository: PLUGIN_REPOSITORY,
authorizationToken: GITHUB_TOKEN,
} );
pluginPath = await test.step(
`Download ${ PLUGIN_NAME } plugin zip`,
async () => {
return downloadZip( {
repository: PLUGIN_REPOSITORY,
authorizationToken: GITHUB_TOKEN,
} );
}
);
// Delete plugin from test site if it's installed.
await deletePlugin( {
request: playwright.request,
baseURL,
slug: pluginSlug,
username: admin.username,
password: admin.password,
await test.step(
"Delete plugin from test site if it's installed.",
async () => {
await deletePluginFromSite( {
request: playwright.request,
baseURL,
} );
}
);
} );
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.afterAll( async ( {} ) => {
// Delete the downloaded zip.
await deleteZip( pluginPath );
} );
test( `can upload and activate "${ PLUGIN_NAME }"`, async ( { page } ) => {
await test.step(
`Install "${ PLUGIN_NAME }" through WP CLI`,
async () => {
await installPluginThruWpCli( pluginPath );
}
);
test( `can upload and activate ${ PLUGIN_NAME }`, async ( { page } ) => {
await installPluginThruWpCli( pluginPath );
await test.step( 'Go to the "Installed Plugins" page', async () => {
await page.goto( 'wp-admin/plugins.php' );
} );
// 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(
`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();
}
);
} );
} );

View File

@ -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!` );
} );
};