diff --git a/packages/e2e-tests/specs/editor/various/sidebar-permalink.test.js b/packages/e2e-tests/specs/editor/various/sidebar-permalink.test.js deleted file mode 100644 index e23bd830cee4fe..00000000000000 --- a/packages/e2e-tests/specs/editor/various/sidebar-permalink.test.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * WordPress dependencies - */ -import { - activatePlugin, - createNewPost, - deactivatePlugin, - publishPost, - canvas, -} from '@wordpress/e2e-test-utils'; - -const urlButtonSelector = '*[aria-label^="Change URL"]'; - -// This tests are not together with the remaining sidebar tests, -// because we need to publish/save a post, to correctly test the permalink row. -// The sidebar test suit enforces that focus is never lost, but during save operations -// the focus is lost and a new element is focused once the save is completed. -describe( 'Sidebar Permalink', () => { - beforeAll( async () => { - await activatePlugin( 'gutenberg-test-custom-post-types' ); - } ); - - afterAll( async () => { - await deactivatePlugin( 'gutenberg-test-custom-post-types' ); - } ); - - it( 'should not render URL when post is publicly queryable but not public', async () => { - await createNewPost( { postType: 'public_q_not_public' } ); - await page.keyboard.type( 'aaaaa' ); - await publishPost(); - // Start editing again. - await canvas().type( '.editor-post-title__input', ' (Updated)' ); - expect( await page.$( urlButtonSelector ) ).toBeNull(); - } ); - - it( 'should not render URL when post is public but not publicly queryable', async () => { - await createNewPost( { postType: 'not_public_q_public' } ); - await page.keyboard.type( 'aaaaa' ); - await publishPost(); - // Start editing again. - await canvas().type( '.editor-post-title__input', ' (Updated)' ); - expect( await page.$( urlButtonSelector ) ).toBeNull(); - } ); - - it( 'should render URL when post is public and publicly queryable', async () => { - await createNewPost( { postType: 'public_q_public' } ); - await page.keyboard.type( 'aaaaa' ); - await publishPost(); - // Start editing again. - await canvas( 0 ).type( '.editor-post-title__input', ' (Updated)' ); - expect( await page.$( urlButtonSelector ) ).not.toBeNull(); - } ); -} ); diff --git a/test/e2e/specs/editor/various/sidebar-permalink.spec.js b/test/e2e/specs/editor/various/sidebar-permalink.spec.js new file mode 100644 index 00000000000000..dcc16844d424a1 --- /dev/null +++ b/test/e2e/specs/editor/various/sidebar-permalink.spec.js @@ -0,0 +1,81 @@ +/** + * WordPress dependencies + */ +const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); + +// This tests are not together with the remaining sidebar tests, +// because we need to publish/save a post, to correctly test the permalink row. +// The sidebar test suit enforces that focus is never lost, but during save operations +// the focus is lost and a new element is focused once the save is completed. +test.describe( 'Sidebar Permalink', () => { + 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 not render URL when post is publicly queryable but not public', async ( { + admin, + editor, + page, + } ) => { + await admin.createNewPost( { postType: 'public_q_not_public' } ); + await editor.openDocumentSettingsSidebar(); + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaaa' ); + await editor.publishPost(); + // Start editing again. + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaa (Updated)' ); + await expect( + page.getByRole( 'button', { name: 'Change URL' } ) + ).toBeHidden(); + } ); + + test( 'should not render URL when post is public but not publicly queryable', async ( { + admin, + editor, + page, + } ) => { + await admin.createNewPost( { postType: 'not_public_q_public' } ); + await editor.openDocumentSettingsSidebar(); + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaaa' ); + await editor.saveDraft(); + // Start editing again. + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaa (Updated)' ); + await expect( + page.getByRole( 'button', { name: 'Change URL' } ) + ).toBeHidden(); + } ); + + test( 'should render URL when post is public and publicly queryable', async ( { + admin, + editor, + page, + } ) => { + await admin.createNewPost( { postType: 'public_q_public' } ); + await editor.openDocumentSettingsSidebar(); + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaaa' ); + await editor.publishPost(); + + // Start editing again. + await editor.canvas + .getByRole( 'textbox', { name: 'Add title' } ) + .fill( 'aaaa (Updated)' ); + await expect( + page.getByRole( 'button', { name: 'Change URL' } ) + ).toBeVisible(); + } ); +} );