Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions tests/e2e/specs/import.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* 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( 'lists popular importers with Install Now actions', async ( {
admin,
page,
} ) => {
await admin.visitAdminPage( 'import.php' );
Comment thread
shail-mehta marked this conversation as resolved.
Resolved

await expect(
page.getByRole( 'heading', { name: 'Import', exact: true } )
).toBeVisible();
await expect(
page.getByRole( 'link', {
name: `Install ${ IMPORTER_NAME } now`,
exact: true,
} )
).toBeVisible();
} );
} );
Loading