Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Playwright e2e test for bulk delete of pages #7991

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
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
43 changes: 43 additions & 0 deletions tests/e2e/specs/pages/bulk-delete-pages.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Bulk Delete wp pages', () => {
test.beforeEach( async ( { page, admin, requestUtils, editor } ) => {
// delete all pages
await requestUtils.deleteAllPages();

const pageTitles = ['Bulk edit page 1', 'Bulk edit page 2']

// create pages
for (const title of pageTitles) {
await admin.createNewPost( {

Check failure on line 15 in tests/e2e/specs/pages/bulk-delete-pages.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk

2) [chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk Error: Not logged in 13 | // create pages 14 | for (const title of pageTitles) { > 15 | await admin.createNewPost( { | ^ 16 | title: title, 17 | postType: 'page', 18 | } ); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/bulk-delete-pages.test.js:15:4

Check failure on line 15 in tests/e2e/specs/pages/bulk-delete-pages.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk

2) [chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 13 | // create pages 14 | for (const title of pageTitles) { > 15 | await admin.createNewPost( { | ^ 16 | title: title, 17 | postType: 'page', 18 | } ); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/bulk-delete-pages.test.js:15:4

Check failure on line 15 in tests/e2e/specs/pages/bulk-delete-pages.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk

2) [chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk Error: Not logged in 13 | // create pages 14 | for (const title of pageTitles) { > 15 | await admin.createNewPost( { | ^ 16 | title: title, 17 | postType: 'page', 18 | } ); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/bulk-delete-pages.test.js:15:4

Check failure on line 15 in tests/e2e/specs/pages/bulk-delete-pages.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk

2) [chromium] › pages/bulk-delete-pages.test.js:25:2 › Bulk Delete wp pages › Should able to delete the pages in bulk Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 13 | // create pages 14 | for (const title of pageTitles) { > 15 | await admin.createNewPost( { | ^ 16 | title: title, 17 | postType: 'page', 18 | } ); at Admin.visitAdminPage (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/visit-admin-page.ts:36:9) at Admin.createNewPost (/home/runner/work/wordpress-develop/wordpress-develop/node_modules/@wordpress/e2e-test-utils-playwright/src/admin/create-new-post.ts:41:2) at /home/runner/work/wordpress-develop/wordpress-develop/tests/e2e/specs/pages/bulk-delete-pages.test.js:15:4
title: title,
postType: 'page',
} );
await editor.publishPost();

}

} );

test( 'Should able to delete the pages in bulk', async ( {
page,
admin,
} ) => {

// visit the page list
await admin.visitAdminPage( '/edit.php?post_type=page' );

await page.getByRole(' checkbox ', {name: 'Select All'}).first().check();

await page.getByRole(' combobox ', {name: "action"}).first().selectOption('trash');

await page.getByRole( 'button', {name: 'Apply'}).first().click();

await expect(
page.locator( "div[id='message'] p" ).first()
).toHaveText( /moved to the Trash./ );
} );
} );
Loading