Skip to content

Commit

Permalink
Migrate CPT e2e tests to Playwright (#50031)
Browse files Browse the repository at this point in the history
* Migrate CPT e2e tests to Playwright

* Remove previous test file
  • Loading branch information
Mamaduka authored Apr 25, 2023
1 parent c7d0b77 commit 62ca715
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 81 deletions.
81 changes: 0 additions & 81 deletions packages/e2e-tests/specs/editor/plugins/custom-post-types.test.js

This file was deleted.

79 changes: 79 additions & 0 deletions test/e2e/specs/editor/plugins/custom-post-types.spec.js
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();
} );
} );

0 comments on commit 62ca715

Please sign in to comment.