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 quick edit of pages #7992

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
44 changes: 44 additions & 0 deletions tests/e2e/specs/pages/quick-edit-page.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* WordPress dependencies
*/
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Quick Edit Page', () => {
test.beforeEach( async ( { requestUtils, admin, editor } ) => {
await requestUtils.deleteAllPages();
await admin.createNewPost( { title: 'QA Page', postType: 'page' } );

Check failure on line 9 in tests/e2e/specs/pages/quick-edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page

2) [chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page Error: Not logged in 7 | test.beforeEach( async ( { requestUtils, admin, editor } ) => { 8 | await requestUtils.deleteAllPages(); > 9 | await admin.createNewPost( { title: 'QA Page', postType: 'page' } ); | ^ 10 | await editor.publishPost(); 11 | } ); 12 | 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/quick-edit-page.test.js:9:3

Check failure on line 9 in tests/e2e/specs/pages/quick-edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG disabled / Run E2E tests

[chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page

2) [chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 7 | test.beforeEach( async ( { requestUtils, admin, editor } ) => { 8 | await requestUtils.deleteAllPages(); > 9 | await admin.createNewPost( { title: 'QA Page', postType: 'page' } ); | ^ 10 | await editor.publishPost(); 11 | } ); 12 | 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/quick-edit-page.test.js:9:3

Check failure on line 9 in tests/e2e/specs/pages/quick-edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page

2) [chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page Error: Not logged in 7 | test.beforeEach( async ( { requestUtils, admin, editor } ) => { 8 | await requestUtils.deleteAllPages(); > 9 | await admin.createNewPost( { title: 'QA Page', postType: 'page' } ); | ^ 10 | await editor.publishPost(); 11 | } ); 12 | 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/quick-edit-page.test.js:9:3

Check failure on line 9 in tests/e2e/specs/pages/quick-edit-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page

2) [chromium] › pages/quick-edit-page.test.js:13:2 › Quick Edit Page › Should be able to quick edit a wp page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 7 | test.beforeEach( async ( { requestUtils, admin, editor } ) => { 8 | await requestUtils.deleteAllPages(); > 9 | await admin.createNewPost( { title: 'QA Page', postType: 'page' } ); | ^ 10 | await editor.publishPost(); 11 | } ); 12 | 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/quick-edit-page.test.js:9:3
await editor.publishPost();
} );

test( 'Should be able to quick edit a wp page', async ( {
page,
admin,
} ) => {
// navigate to All Pages
await admin.visitAdminPage( '/edit.php?post_type=page' );

// hover over the page created
await page.hover( 'role=link[name= "“QA Page” (Edit)"i]' );

// click on quick edit
await page.getByRole( 'button', { name: 'Quick Edit' } ).click();

// validate the title to check correct page is being edited
await expect(
page.getByRole( 'textbox', { name: 'Title', exact: true } )
).toHaveValue( 'QA Page' );

// Updated title of the page
await page
.getByRole( 'textbox', { name: 'Title' } )
.fill( 'Edited from quick edit' );

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

// Validate title after quick edit
await expect(
page.getByRole( 'link', { name: 'Edited from quick edit” (Edit)' } )
).toContainText( 'Edited from quick edit' );
} );
} );
Loading