From 5394e99a492973146cf25e8bad13a9e3608b1f89 Mon Sep 17 00:00:00 2001 From: Jayson Rodrigues Date: Wed, 11 Dec 2024 14:55:27 +0530 Subject: [PATCH] Add Playwright e2e test for bulk delete of pages --- .../e2e/specs/pages/bulk-delete-pages.test.js | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 tests/e2e/specs/pages/bulk-delete-pages.test.js diff --git a/tests/e2e/specs/pages/bulk-delete-pages.test.js b/tests/e2e/specs/pages/bulk-delete-pages.test.js new file mode 100644 index 0000000000000..7400af8806390 --- /dev/null +++ b/tests/e2e/specs/pages/bulk-delete-pages.test.js @@ -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( { + 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./ ); + } ); +} );