-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate CPT e2e tests to Playwright (#50031)
* Migrate CPT e2e tests to Playwright * Remove previous test file
- Loading branch information
Showing
2 changed files
with
79 additions
and
81 deletions.
There are no files selected for viewing
81 changes: 0 additions & 81 deletions
81
packages/e2e-tests/specs/editor/plugins/custom-post-types.test.js
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
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(); | ||
} ); | ||
} ); |