-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Migrate CPT e2e tests to Playwright #50031
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/** | ||
* WordPress dependencies | ||
*/ | ||
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); | ||
|
||
test.describe( 'Test Custom Post Types', () => { | ||
test.beforeAll( async ( { requestUtils } ) => { | ||
await requestUtils.activatePlugin( 'gutenberg-test-custom-post-types' ); | ||
} ); | ||
|
||
test.afterAll( async ( { requestUtils } ) => { | ||
await requestUtils.deactivatePlugin( | ||
'gutenberg-test-custom-post-types' | ||
); | ||
} ); | ||
|
||
test( 'should be able to create an hierarchical post without title support', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost( { postType: 'hierar-no-title' } ); | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( 'Parent Post' ); | ||
await editor.publishPost(); | ||
|
||
// Create a post that is a child of the previously created post. | ||
await admin.createNewPost( { postType: 'hierar-no-title' } ); | ||
await editor.openDocumentSettingsSidebar(); | ||
await page | ||
.getByRole( 'region', { name: 'Editor settings' } ) | ||
.getByRole( 'button', { | ||
name: 'Hierarchical No Title', | ||
} ) | ||
.click(); | ||
|
||
// Open the Document -> Page Attributes panel. | ||
await page.getByRole( 'button', { name: 'Page Attributes' } ).click(); | ||
|
||
const parentPageLocator = page.getByRole( 'combobox', { | ||
name: 'Parent Page', | ||
} ); | ||
|
||
await parentPageLocator.click(); | ||
await page.getByRole( 'listbox' ).getByRole( 'option' ).first().click(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Could we add some parent locator to make it a bit easier to read here? There could be multiple listboxs on the same page. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
const parentPage = await parentPageLocator.inputValue(); | ||
|
||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( 'Child Post' ); | ||
await editor.publishPost(); | ||
await page.reload(); | ||
|
||
// Confirm parent page selection matches after reloading. | ||
await expect( parentPageLocator ).toHaveValue( parentPage ); | ||
} ); | ||
|
||
test( 'should create a cpt with a legacy block in its template without WSOD', async ( { | ||
admin, | ||
editor, | ||
page, | ||
} ) => { | ||
await admin.createNewPost( { postType: 'leg_block_in_tpl' } ); | ||
await page.click( 'role=button[name="Add default block"i]' ); | ||
await page.keyboard.type( 'Hello there' ); | ||
|
||
await expect.poll( editor.getBlocks ).toMatchObject( [ | ||
{ | ||
name: 'core/embed', | ||
attributes: { providerNameSlug: 'wordpress-tv' }, | ||
}, | ||
{ | ||
name: 'core/paragraph', | ||
attributes: { content: 'Hello there' }, | ||
}, | ||
] ); | ||
|
||
await editor.publishPost(); | ||
} ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test doesn't care which option we select; only that selection remains after reloading. The options are populated based on the post ID, so it's hard to provide them explicitly.