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 post edit #8045

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

test.describe( 'Bulk @wp-post Edit', () => {
test.beforeEach( async ( { admin, editor } ) => {
// create Posts to use in test
const postTitles = [
'Test Post for bulk edit 1',
'Test Post for bulk edit 2',
];

for ( const title of postTitles ) {
await admin.createNewPost( { title: title } );

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

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk

2) [chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk Error: Not logged in 13 | 14 | for ( const title of postTitles ) { > 15 | await admin.createNewPost( { title: title } ); | ^ 16 | await editor.publishPost(); 17 | } 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/posts/post-bulk-edit.test.js:15:4

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

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk

2) [chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 13 | 14 | for ( const title of postTitles ) { > 15 | await admin.createNewPost( { title: title } ); | ^ 16 | await editor.publishPost(); 17 | } 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/posts/post-bulk-edit.test.js:15:4

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

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk

2) [chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk Error: Not logged in 13 | 14 | for ( const title of postTitles ) { > 15 | await admin.createNewPost( { title: title } ); | ^ 16 | await editor.publishPost(); 17 | } 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/posts/post-bulk-edit.test.js:15:4

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

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk

2) [chromium] › posts/post-bulk-edit.test.js:24:2 › Bulk @wp-post Edit › Should be able to edit the posts in bulk Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 13 | 14 | for ( const title of postTitles ) { > 15 | await admin.createNewPost( { title: title } ); | ^ 16 | await editor.publishPost(); 17 | } 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/posts/post-bulk-edit.test.js:15:4
await editor.publishPost();
}
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllPosts();
} );

test( 'Should be able to edit the posts in bulk', async ( {
page,
admin,
} ) => {
// Navigate to posts page
await admin.visitAdminPage( '/edit.php' );
await expect( page.locator( '.wp-heading-inline' ) ).toHaveText(
'Posts'
);

// click on select all checkbox
await page.locator( '#cb-select-all-1' ).click();

// select the edit option from the dropdown
await page.selectOption( '#bulk-action-selector-top', 'edit' );

// click on apply button
await page.click( 'role=button[name="Apply"i] >> nth=0' );

// select the draft option
await page
.getByRole( 'combobox', { name: 'Status' } )
.selectOption( 'draft' );

// click on the update button
await page.getByRole( 'button', { name: 'Update' } ).click();

await expect(
page.locator( "div[id='message'] p" ).first()
).toHaveText( /posts updated./ );

const listTable = page.getByRole( 'table', {
name: 'Table ordered by',
} );
const posts = listTable.locator( '.page-title strong span' );

// Validate that the page is in draft status
await expect( posts.first() ).toHaveText( 'Draft' );
} );
} );
Loading