diff --git a/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js b/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js deleted file mode 100644 index e61927e10ff17f..00000000000000 --- a/packages/e2e-tests/specs/editor/various/new-post-default-content.test.js +++ /dev/null @@ -1,52 +0,0 @@ -/** - * WordPress dependencies - */ -import { - activatePlugin, - createNewPost, - deactivatePlugin, - findSidebarPanelToggleButtonWithTitle, - getEditedPostContent, - openDocumentSettingsSidebar, -} from '@wordpress/e2e-test-utils'; - -describe( 'new editor filtered state', () => { - beforeAll( async () => { - await activatePlugin( 'gutenberg-test-plugin-default-post-content' ); - } ); - - beforeEach( async () => { - await createNewPost(); - } ); - - afterAll( async () => { - await deactivatePlugin( 'gutenberg-test-plugin-default-post-content' ); - } ); - - it( 'should respect default content', async () => { - // Get the values that should have their defaults changed. - const title = await page.$eval( - '.editor-post-title__input', - ( element ) => element.innerHTML - ); - const content = await getEditedPostContent(); - - // open the sidebar, we want to see the excerpt. - await openDocumentSettingsSidebar(); - const excerptButton = await findSidebarPanelToggleButtonWithTitle( - 'Excerpt' - ); - if ( excerptButton ) { - await excerptButton.click( 'button' ); - } - const excerpt = await page.$eval( - '.editor-post-excerpt textarea', - ( element ) => element.innerHTML - ); - - // Assert they match what the plugin set. - expect( title ).toBe( 'My default title' ); - expect( content ).toBe( 'My default content' ); - expect( excerpt ).toBe( 'My default excerpt' ); - } ); -} ); diff --git a/test/e2e/specs/editor/various/new-post-default-content.spec.js b/test/e2e/specs/editor/various/new-post-default-content.spec.js new file mode 100644 index 00000000000000..82c8e3a948f31b --- /dev/null +++ b/test/e2e/specs/editor/various/new-post-default-content.spec.js @@ -0,0 +1,39 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +test.describe( 'new editor filtered state', () => { + test.beforeAll( async ( { requestUtils } ) => { + await requestUtils.activatePlugin( + 'gutenberg-test-plugin-default-post-content' + ); + } ); + + test.beforeEach( async ( { admin } ) => { + await admin.createNewPost(); + } ); + + test.afterAll( async ( { requestUtils } ) => { + await requestUtils.deactivatePlugin( + 'gutenberg-test-plugin-default-post-content' + ); + await requestUtils.deleteAllPosts(); + } ); + + test( 'should respect default content', async ( { editor, page } ) => { + await editor.openDocumentSettingsSidebar(); + await page.click( 'role=button[name="Excerpt"i]' ); + + // Assert they match what the plugin set. + await expect( + page.locator( 'role=textbox[name="Add title"i]' ) + ).toHaveText( 'My default title' ); + await expect + .poll( editor.getEditedPostContent ) + .toBe( 'My default content' ); + await expect( + page.locator( 'role=textbox[name="Write an excerpt (optional)"i]' ) + ).toHaveText( 'My default excerpt' ); + } ); +} );