Skip to content

Commit

Permalink
Polish
Browse files Browse the repository at this point in the history
  • Loading branch information
ellatrix committed Nov 2, 2021
1 parent 2e0dda8 commit c3f9be9
Showing 10 changed files with 16 additions and 60 deletions.
Original file line number Diff line number Diff line change
@@ -47,7 +47,7 @@ export default function EmbeddedAdminContext( props ) {
if ( element !== event.path[ 0 ] ) return;
if ( event.keyCode !== ENTER && event.keyCode !== SPACE ) return;

focus.focusable.find( root )[ 0 ].focus();
focus.tabbable.find( root )[ 0 ].focus();
event.preventDefault();
}

1 change: 0 additions & 1 deletion packages/block-editor/src/components/placeholder/index.js
Original file line number Diff line number Diff line change
@@ -26,7 +26,6 @@ export default function IsolatedPlaceholder( props ) {
<Placeholder
{ ...props }
role="dialog"
aria-label={ props.label }
ref={ useConstrainedTabbing() }
/>
</EmbeddedAdminContext>
2 changes: 1 addition & 1 deletion packages/e2e-test-utils/src/click-placeholder-button.js
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ export async function clickPlaceholderButton( buttonText ) {

for ( const placeholder of placeholders ) {
const buttons = placeholder.shadowRoot.querySelectorAll(
'button,label'
'button,label,[aria-label]'
);

for ( const button of buttons ) {
10 changes: 2 additions & 8 deletions packages/e2e-tests/specs/editor/plugins/cpt-locking.test.js
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@ import {
activatePlugin,
clickBlockToolbarButton,
clickMenuItem,
clickPlaceholderButton,
createNewPost,
deactivatePlugin,
getEditedPostContent,
@@ -119,14 +120,7 @@ describe( 'cpt locking', () => {
} );

it( 'can use the global inserter in inner blocks', async () => {
await page.evaluate( () => {
document
.querySelector( '.wp-block-columns > div' )
.shadowRoot.querySelector(
'[aria-label="Two columns; equal split"]'
)
.focus();
} );
await clickPlaceholderButton( 'Two columns; equal split' );
await page.keyboard.press( 'Enter' );
await page.click(
'.wp-block-column .block-editor-button-block-appender'
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@ import {
createEmbeddingMatcher,
createJSONResponse,
setUpResponseMocking,
clickPlaceholderButton,
} from '@wordpress/e2e-test-utils';

const MOCK_RESPONSES = [
@@ -43,10 +44,7 @@ describe( 'Embed block inside a locked all parent', () => {

it( 'embed block should be able to embed external content', async () => {
await insertBlock( 'Test Inner Blocks Locking All Embed' );
const handle = await page.evaluateHandle(
`document.querySelector('.wp-block-embed [role="button"]').shadowRoot.querySelector('input')`
);
await handle.click( handle );
await clickPlaceholderButton( 'Embed URL' );
// This URL should not have a trailing slash.
await page.keyboard.type( 'https://twitter.com/wordpress' );
await page.keyboard.press( 'Enter' );
Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ describe( 'block deletion -', () => {

// Click on the image block so that its wrapper is selected and backspace to delete it.
await page.click(
'.wp-block[data-type="core/image"] [role="button"]'
'.wp-block[data-type="core/image"] .wp-block-editor-placeholder'
);
await page.keyboard.press( 'Backspace' );

@@ -190,7 +190,6 @@ describe( 'deleting all blocks', () => {
// Add and remove a block.
await insertBlock( 'Image' );
await page.waitForSelector( 'figure[data-type="core/image"]' );
await page.click( 'figure[data-type="core/image"]' );
await page.keyboard.press( 'Backspace' );

// Verify there is no selected block.
Original file line number Diff line number Diff line change
@@ -94,6 +94,7 @@ describe( 'Navigating the block hierarchy', () => {

it( 'should navigate block hierarchy using only the keyboard', async () => {
await insertBlock( 'Columns' );
await openDocumentSettingsSidebar();
await clickPlaceholderButton( 'Two columns; equal split' );

// Add a paragraph in the first column.
@@ -110,7 +111,6 @@ describe( 'Navigating the block hierarchy', () => {
await page.keyboard.press( 'Enter' );

// Move focus to the sidebar area.
await openDocumentSettingsSidebar();
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
await pressKeyWithModifier( 'ctrl', '`' );
40 changes: 6 additions & 34 deletions packages/e2e-tests/specs/editor/various/embedding.test.js
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
*/
import {
clickBlockAppender,
clickPlaceholderButton,
createEmbeddingMatcher,
createJSONResponse,
createNewPost,
@@ -191,7 +192,7 @@ describe( 'Embedding content', () => {
await insertEmbed( 'https://twitter.com/wooyaygutenberg123454312' );
await page.waitForFunction( () => {
const embedPlaceholders = document.querySelectorAll(
'.wp-block-embed [role="button"]'
'.wp-block-editor-placeholder'
);
const lastEmbedPlaceholder =
embedPlaceholders[ embedPlaceholders.length - 1 ];
@@ -204,7 +205,7 @@ describe( 'Embedding content', () => {
await insertEmbed( 'https://wordpress.org/gutenberg/handbook/' );
await page.waitForFunction( () => {
const embedPlaceholders = document.querySelectorAll(
'.wp-block-embed [role="button"]'
'.wp-block-editor-placeholder'
);
const lastEmbedPlaceholder =
embedPlaceholders[ embedPlaceholders.length - 1 ];
@@ -218,7 +219,7 @@ describe( 'Embedding content', () => {
await insertEmbed( 'https://twitter.com/thatbunty' );
await page.waitForFunction( () => {
const embedPlaceholders = document.querySelectorAll(
'.wp-block-embed [role="button"]'
'.wp-block-editor-placeholder'
);
const lastEmbedPlaceholder =
embedPlaceholders[ embedPlaceholders.length - 1 ];
@@ -253,22 +254,7 @@ describe( 'Embedding content', () => {
it( 'should allow the user to convert unembeddable URLs to a paragraph with a link in it', async () => {
// URL that can't be embedded.
await insertEmbed( 'https://twitter.com/wooyaygutenberg123454312' );

await page.waitForFunction( () => {
const embedPlaceholders = document.querySelectorAll(
'.wp-block-embed [role="button"]'
);
const lastEmbedPlaceholder =
embedPlaceholders[ embedPlaceholders.length - 1 ];
return lastEmbedPlaceholder?.shadowRoot.querySelector(
'input[value="https://twitter.com/wooyaygutenberg123454312"]'
);
} );

const handle = await page.evaluateHandle(
`document.querySelector('.wp-block-embed [role="button"]').shadowRoot.querySelector('.components-placeholder__error').lastElementChild`
);
await handle.click( handle );
await clickPlaceholderButton( 'Convert to link' );

expect( await getEditedPostContent() ).toMatchSnapshot();
} );
@@ -284,17 +270,6 @@ describe( 'Embedding content', () => {
// URL that can't be embedded.
await insertEmbed( 'https://twitter.com/wooyaygutenberg123454312' );

await page.waitForFunction( () => {
const embedPlaceholders = document.querySelectorAll(
'.wp-block-embed [role="button"]'
);
const lastEmbedPlaceholder =
embedPlaceholders[ embedPlaceholders.length - 1 ];
return lastEmbedPlaceholder?.shadowRoot.querySelector(
'input[value="https://twitter.com/wooyaygutenberg123454312"]'
);
} );

// Set up a different mock to make sure that try again actually does make the request again.
await setUpResponseMocking( [
{
@@ -306,10 +281,7 @@ describe( 'Embedding content', () => {
),
},
] );
const handle = await page.evaluateHandle(
`document.querySelector('.wp-block-embed [role="button"]').shadowRoot.querySelector('button.is-secondary')`
);
await handle.click( handle );
await clickPlaceholderButton( 'Try again' );
await page.waitForSelector( 'figure.wp-block-embed' );
expect( await getEditedPostContent() ).toMatchSnapshot();
} );
Original file line number Diff line number Diff line change
@@ -6,11 +6,8 @@ import {
pressKeyWithModifier,
clickBlockToolbarButton,
insertBlock,
clickPlaceholderButton,
} from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { clickPlaceholderButton } from '../../../../e2e-test-utils/src';

async function focusBlockToolbar() {
await pressKeyWithModifier( 'alt', 'F10' );
Original file line number Diff line number Diff line change
@@ -9,11 +9,8 @@ import {
trashAllPosts,
activateTheme,
clickButton,
clickPlaceholderButton,
} from '@wordpress/e2e-test-utils';
/**
* Internal dependencies
*/
import { clickPlaceholderButton } from '../../../e2e-test-utils/src';

/**
* Internal dependencies

0 comments on commit c3f9be9

Please sign in to comment.