Skip to content

Commit

Permalink
Migrate 'sidebar permalink' e2e tests to Playwright (#56253)
Browse files Browse the repository at this point in the history
* Migrate 'sidebar permalink' e2e tests to Playwright

Co-authored-by: Pavan  Patil <44057535+pavanpatil1@users.noreply.github.com>

* Remove old test file

* Open document settings sidebar

---------

Co-authored-by: Pavan  Patil <44057535+pavanpatil1@users.noreply.github.com>
  • Loading branch information
Mamaduka and pavanpatil1 committed Nov 21, 2023
1 parent 1587cb9 commit fe958de
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 53 deletions.
53 changes: 0 additions & 53 deletions packages/e2e-tests/specs/editor/various/sidebar-permalink.test.js

This file was deleted.

81 changes: 81 additions & 0 deletions test/e2e/specs/editor/various/sidebar-permalink.spec.js
Original file line number Diff line number Diff line change
@@ -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();
} );
} );

0 comments on commit fe958de

Please sign in to comment.