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 to add a new page #7998

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

test.describe( 'Add New wp page', () => {
test.beforeEach( async ( { admin, requestUtils } ) => {
// delete all pages
await requestUtils.deleteAllPages();
// Open the new page editor
await admin.createNewPost( { postType: 'page' } );

Check failure on line 11 in tests/e2e/specs/pages/add-new-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page

2) [chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page ─────── Error: Not logged in 9 | await requestUtils.deleteAllPages(); 10 | // Open the new page editor > 11 | await admin.createNewPost( { postType: 'page' } ); | ^ 12 | } ); 13 | 14 | test( 'Should create new page', async ( { page, admin } ) => { 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/add-new-page.test.js:11:3

Check failure on line 11 in tests/e2e/specs/pages/add-new-page.test.js

View workflow job for this annotation

GitHub Actions / Test with SCRIPT_DEBUG enabled / Run E2E tests

[chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page

2) [chromium] › pages/add-new-page.test.js:14:2 › Add New wp page › Should create new page ─────── Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Not logged in 9 | await requestUtils.deleteAllPages(); 10 | // Open the new page editor > 11 | await admin.createNewPost( { postType: 'page' } ); | ^ 12 | } ); 13 | 14 | test( 'Should create new page', async ( { page, admin } ) => { 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/add-new-page.test.js:11:3
} );

test( 'Should create new page', async ( { page, admin } ) => {
// Check if the template modal is visible and close it
/* if ( page.locator( '.components-modal__content' ).isVisible() ) {
await page.getByLabel( 'Close', { exact: true } ).click();
} */

// Fill the title of the page
await page
.frameLocator( 'iframe[name="editor-canvas"]' )
.getByRole( 'textbox', { name: 'Add title' } )
.fill( 'Test Page' );

// Move to the next field means the description field
await page.keyboard.press( 'ArrowDown' );

// Add the description for the page
await page.keyboard.type( 'Test page description' );

//Click on publish button
await page.click( '.editor-post-publish-panel__toggle' );

//Double check, click again on publish button
await page.click( '.editor-post-publish-button' );

// A success notice should show up
await expect( page.locator( '.components-snackbar' ) ).toBeVisible();

// visit all pages page
await admin.visitAdminPage( '/edit.php?post_type=page' );

// validate that the created page is present
await expect(
page.getByRole( 'link', { name: '“Test Page” (Edit)' } )
).toBeVisible();
} );
} );
Loading