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 e2e test for post bulk delete #8040

Open
wants to merge 3 commits 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
39 changes: 39 additions & 0 deletions tests/e2e/specs/posts/post-bulk-delete.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* WordPress dependencies
*/
const { test, expect } = require("@wordpress/e2e-test-utils-playwright");


test.describe("Bulk Delete Posts", () => {

test.beforeEach(async ({ admin, editor }) => {
// Create multiple posts for bulk deletion
for (let i = 0; i < 2; i++) {
const title = `Test Post ${i + 1}`;
await admin.createNewPost({ title });

Check failure on line 13 in tests/e2e/specs/posts/post-bulk-delete.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › posts/post-bulk-delete.test.js:18:3 › Bulk Delete Posts › Can delete the posts in bulk

2) [chromium] › posts/post-bulk-delete.test.js:18:3 › Bulk Delete Posts › Can delete the posts in bulk Error: Not logged in 11 | for (let i = 0; i < 2; i++) { 12 | const title = `Test Post ${i + 1}`; > 13 | await admin.createNewPost({ title }); | ^ 14 | await editor.publishPost(); 15 | } 16 | }); 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/posts/post-bulk-delete.test.js:13:7

Check failure on line 13 in tests/e2e/specs/posts/post-bulk-delete.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › posts/post-bulk-delete.test.js:18:3 › Bulk Delete Posts › Can delete the posts in bulk

2) [chromium] › posts/post-bulk-delete.test.js:18:3 › Bulk Delete Posts › Can delete the posts in bulk Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 11 | for (let i = 0; i < 2; i++) { 12 | const title = `Test Post ${i + 1}`; > 13 | await admin.createNewPost({ title }); | ^ 14 | await editor.publishPost(); 15 | } 16 | }); 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/posts/post-bulk-delete.test.js:13:7
await editor.publishPost();
}
});

test("Can delete the posts in bulk", async ({ page, admin }) => {

// Navigate to posts page
await admin.visitAdminPage('/edit.php');

// Assert the Posts page header
expect(page.locator('.wp-heading-inline')).toHaveText('Posts');

// Select all posts for bulk deletion
// await page.locator('#cb-select-all-1').click();
await page.locator('#cb-select-all-1').check();

// Select "Trash" option from the bulk actions dropdown
await page.selectOption('#bulk-action-selector-top', 'trash');
// Apply the bulk action
await page.locator('#doaction').click();

// Assert that posts were moved to the trash
await expect(page.locator("div[id='message'] p").first()).toHaveText(/moved to the Trash./);

});
});
Loading