From df128c789e39726a01e8fef7fb10305ae7cba605 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Fri, 6 Nov 2026 15:00:33 +0000 Subject: [PATCH 1/5] Tests: Cover Import screen importer listing and plugin install in admin E2E. --- tests/e2e/specs/import.test.js | 95 ++++++++++++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/e2e/specs/import.test.js diff --git a/tests/e2e/specs/import.test.js b/tests/e2e/specs/import.test.js new file mode 100644 index 0000000000000..60d512f28ba59 --- /dev/null +++ b/tests/e2e/specs/import.test.js @@ -0,0 +1,95 @@ +/** + * WordPress dependencies + */ +import { test, expect } from '@wordpress/e2e-test-utils-playwright'; + +const IMPORTER_SLUG = 'wordpress-importer'; +const IMPORTER_NAME = 'WordPress'; + +/** + * Deletes the WordPress importer plugin if it is installed. + * + * @param {import('@wordpress/e2e-test-utils-playwright').RequestUtils} requestUtils REST helpers. + */ +async function deleteWordPressImporter( requestUtils ) { + const plugins = await requestUtils.rest( { path: '/wp/v2/plugins' } ); + const installed = plugins.find( ( item ) => + item.plugin.startsWith( `${ IMPORTER_SLUG }/` ) + ); + if ( ! installed ) { + return; + } + if ( installed.status !== 'inactive' ) { + await requestUtils.rest( { + method: 'PUT', + path: `/wp/v2/plugins/${ installed.plugin }`, + data: { status: 'inactive' }, + } ); + } + await requestUtils.rest( { + method: 'DELETE', + path: `/wp/v2/plugins/${ installed.plugin }`, + } ); +} + +test.describe( 'Import', () => { + test.beforeEach( async ( { requestUtils } ) => { + await deleteWordPressImporter( requestUtils ); + } ); + + test.afterEach( async ( { requestUtils } ) => { + await deleteWordPressImporter( requestUtils ); + } ); + + test( 'lists popular importers with Install Now actions', async ( { + admin, + page, + } ) => { + await admin.visitAdminPage( 'import.php' ); + + await expect( + page.getByRole( 'heading', { name: 'Import', exact: true } ) + ).toBeVisible(); + await expect( page.locator( 'table.importers' ) ).toBeVisible(); + await expect( + page.locator( '.importer-title', { hasText: IMPORTER_NAME } ) + ).toBeVisible(); + await expect( + page.getByRole( 'link', { + name: `Install ${ IMPORTER_NAME } now`, + exact: true, + } ) + ).toBeVisible(); + } ); + + test( 'installs the WordPress importer plugin from the Import screen', async ( { + admin, + page, + requestUtils, + } ) => { + // Installing from wordpress.org can take longer than the default timeout. + test.setTimeout( 300_000 ); + + await admin.visitAdminPage( 'import.php' ); + await page + .getByRole( 'link', { + name: `Install ${ IMPORTER_NAME } now`, + exact: true, + } ) + .click(); + + await expect( + page.getByRole( 'link', { + name: `Run ${ IMPORTER_NAME }`, + exact: true, + } ) + ).toBeVisible( { timeout: 180_000 } ); + + const plugins = await requestUtils.rest( { path: '/wp/v2/plugins' } ); + expect( + plugins.some( ( item ) => + item.plugin.startsWith( `${ IMPORTER_SLUG }/` ) + ) + ).toBe( true ); + } ); +} ); From 349fe19c0cce862e16dd0914da8faec584d96c18 Mon Sep 17 00:00:00 2001 From: Shail Mehta Date: Fri, 6 Nov 2026 20:36:00 +0530 Subject: [PATCH 2/5] Refactor visibility check for 'Run Importer' link Update the selector for the 'Run Importer' link to improve visibility check. Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- tests/e2e/specs/import.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/e2e/specs/import.test.js b/tests/e2e/specs/import.test.js index 60d512f28ba59..501f3b9571da0 100644 --- a/tests/e2e/specs/import.test.js +++ b/tests/e2e/specs/import.test.js @@ -79,10 +79,10 @@ test.describe( 'Import', () => { .click(); await expect( - page.getByRole( 'link', { - name: `Run ${ IMPORTER_NAME }`, - exact: true, - } ) + page.locator( + `a[data-slug="${ IMPORTER_SLUG }"].activate-now`, + { hasText: 'Run Importer' } + ) ).toBeVisible( { timeout: 180_000 } ); const plugins = await requestUtils.rest( { path: '/wp/v2/plugins' } ); From 4564c55c31012d9be876b1521381387d1cd7aa0f Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Fri, 6 Nov 2026 15:20:16 +0000 Subject: [PATCH 3/5] Tests: From d2adb7f1e9b7f67d013a6ef0af5b1d86a9b6aba1 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Fri, 6 Nov 2026 15:20:45 +0000 Subject: [PATCH 4/5] Tests: Retrigger CI after Composer network flake. From ccdcd2a332e2d1a6d0f8f6cc8428ba00f11852e9 Mon Sep 17 00:00:00 2001 From: shail-mehta Date: Sat, 7 Nov 2026 03:50:57 +0000 Subject: [PATCH 5/5] Tests: Drop live WordPress.org importer install from Import E2E. Remove the network-backed install coverage and CSS-class locators so the Import screen check stays offline-friendly and uses role/text locators. --- tests/e2e/specs/import.test.js | 39 ---------------------------------- 1 file changed, 39 deletions(-) diff --git a/tests/e2e/specs/import.test.js b/tests/e2e/specs/import.test.js index 501f3b9571da0..32203d18e1b57 100644 --- a/tests/e2e/specs/import.test.js +++ b/tests/e2e/specs/import.test.js @@ -37,10 +37,6 @@ test.describe( 'Import', () => { await deleteWordPressImporter( requestUtils ); } ); - test.afterEach( async ( { requestUtils } ) => { - await deleteWordPressImporter( requestUtils ); - } ); - test( 'lists popular importers with Install Now actions', async ( { admin, page, @@ -50,10 +46,6 @@ test.describe( 'Import', () => { await expect( page.getByRole( 'heading', { name: 'Import', exact: true } ) ).toBeVisible(); - await expect( page.locator( 'table.importers' ) ).toBeVisible(); - await expect( - page.locator( '.importer-title', { hasText: IMPORTER_NAME } ) - ).toBeVisible(); await expect( page.getByRole( 'link', { name: `Install ${ IMPORTER_NAME } now`, @@ -61,35 +53,4 @@ test.describe( 'Import', () => { } ) ).toBeVisible(); } ); - - test( 'installs the WordPress importer plugin from the Import screen', async ( { - admin, - page, - requestUtils, - } ) => { - // Installing from wordpress.org can take longer than the default timeout. - test.setTimeout( 300_000 ); - - await admin.visitAdminPage( 'import.php' ); - await page - .getByRole( 'link', { - name: `Install ${ IMPORTER_NAME } now`, - exact: true, - } ) - .click(); - - await expect( - page.locator( - `a[data-slug="${ IMPORTER_SLUG }"].activate-now`, - { hasText: 'Run Importer' } - ) - ).toBeVisible( { timeout: 180_000 } ); - - const plugins = await requestUtils.rest( { path: '/wp/v2/plugins' } ); - expect( - plugins.some( ( item ) => - item.plugin.startsWith( `${ IMPORTER_SLUG }/` ) - ) - ).toBe( true ); - } ); } );