Skip to content

Commit

Permalink
Update E2E tests
Browse files Browse the repository at this point in the history
  • Loading branch information
noisysocks committed Jul 1, 2022
1 parent 82766b7 commit 8ddbcde
Showing 1 changed file with 10 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import {
activatePlugin,
createNewPost,
deactivatePlugin,
findSidebarPanelWithTitle,
publishPost,
} from '@wordpress/e2e-test-utils';

const permalinkPanelXPath = `//div[contains(@class, "edit-post-sidebar")]//button[contains(@class, "components-panel__body-toggle") and contains(text(),"Permalink")]`;
// TODO: Use a more accessible selector.
const urlRowSelector = '.edit-post-post-url';

// This tests are not together with the remaining sidebar tests,
// because we need to publish/save a post, to correctly test the permalink panel.
// 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 Panel', () => {
describe( 'Sidebar Permalink', () => {
beforeAll( async () => {
await activatePlugin( 'gutenberg-test-custom-post-types' );
} );
Expand All @@ -24,39 +24,30 @@ describe( 'Sidebar Permalink Panel', () => {
await deactivatePlugin( 'gutenberg-test-custom-post-types' );
} );

it( 'should allow permalink sidebar panel to be removed', async () => {
await createNewPost();
await page.evaluate( () => {
const { removeEditorPanel } = wp.data.dispatch( 'core/edit-post' );
removeEditorPanel( 'post-link' );
} );
expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
} );

it( 'should not render link panel when post is publicly queryable but not public', async () => {
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 page.type( '.editor-post-title__input', ' (Updated)' );
expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
expect( await page.$( urlRowSelector ) ).toBeNull();
} );

it( 'should not render link panel when post is public but not publicly queryable', async () => {
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 page.type( '.editor-post-title__input', ' (Updated)' );
expect( await page.$x( permalinkPanelXPath ) ).toEqual( [] );
expect( await page.$( urlRowSelector ) ).toBeNull();
} );

it( 'should render link panel when post is public and publicly queryable', async () => {
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 page.type( '.editor-post-title__input', ' (Updated)' );
expect( await findSidebarPanelWithTitle( 'Permalink' ) ).toBeDefined();
expect( await page.$( urlRowSelector ) ).not.toBeNull();
} );
} );

0 comments on commit 8ddbcde

Please sign in to comment.