Skip to content

Commit

Permalink
Add Playwright e2e test for bulk delete of pages
Browse files Browse the repository at this point in the history
  • Loading branch information
jayson31 committed Dec 11, 2024
1 parent 27c566f commit 5394e99
Showing 1 changed file with 43 additions and 0 deletions.
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./ );
} );
} );

0 comments on commit 5394e99

Please sign in to comment.