Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Block Bindings: Prepare the ground to define fieldsList on the server. #67802

Draft
wants to merge 4 commits into
base: trunk
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/compat/wordpress-6.7/block-bindings.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'name' => $source->name,
'label' => $source->label,
'usesContext' => $source->uses_context,
'args' => $source->args,

Check warning on line 20 in lib/compat/wordpress-6.7/block-bindings.php

View workflow job for this annotation

GitHub Actions / PHP coding standards

Array double arrow not aligned correctly; expected 8 space(s) between "'args'" and double arrow, but found 3.
);
}
$script = sprintf( 'for ( const source of %s ) { ! wp.blocks.getBlockBindingsSource( source.name ) && wp.blocks.registerBlockBindingsSource( source ); }', wp_json_encode( $filtered_sources ) );
Expand Down
2 changes: 1 addition & 1 deletion packages/block-editor/src/components/rich-text/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ export function RichTextWrapper(

const { getBlockAttributes } = select( blockEditorStore );
const blockAttributes = getBlockAttributes( clientId );
const fieldsList = blockBindingsSource?.getFieldsList?.( {
const fieldsList = blockBindingsSource?.args?.( {
select,
context: blockBindingsContext,
} );
Expand Down
21 changes: 13 additions & 8 deletions packages/block-editor/src/hooks/block-bindings.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,9 +209,9 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
const bindableAttributes = getBindableAttributes( blockName );
const dropdownMenuProps = useToolsPanelDropdownMenuProps();

// `useSelect` is used purposely here to ensure `getFieldsList`
// `useSelect` is used purposely here to ensure `args`
// is updated whenever there are updates in block context.
// `source.getFieldsList` may also call a selector via `select`.
// `source.args` may also call a selector via `select`.
const _fieldsList = {};
const { fieldsList, canUpdateBlockBindings } = useSelect(
( select ) => {
Expand All @@ -220,19 +220,24 @@ export const BlockBindingsPanel = ( { name: blockName, metadata } ) => {
}
const registeredSources = getBlockBindingsSources();
Object.entries( registeredSources ).forEach(
( [ sourceName, { getFieldsList, usesContext } ] ) => {
if ( getFieldsList ) {
( [ sourceName, { args, usesContext } ] ) => {
if ( args ) {
// Populate context.
const context = {};
if ( usesContext?.length ) {
for ( const key of usesContext ) {
context[ key ] = blockContext[ key ];
}
}
const sourceList = getFieldsList( {
select,
context,
} );
let sourceList;
if ( typeof args === 'function' ) {
sourceList = args( {
select,
context,
} );
} else {
sourceList = { ...args };
}
// Only add source if the list is not empty.
if ( Object.keys( sourceList || {} ).length ) {
_fieldsList[ sourceName ] = { ...sourceList };
Expand Down
12 changes: 5 additions & 7 deletions packages/blocks/src/api/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ export const registerBlockBindingsSource = ( source ) => {
getValues,
setValues,
canUserEditValue,
getFieldsList,
args,
} = source;

const existingSource = unlock(
Expand All @@ -811,6 +811,7 @@ export const registerBlockBindingsSource = ( source ) => {
* Check if the source has been already registered on the client.
* If any property expected to be "client-only" is defined, return a warning.
*/
// TODO: Check if server prop fields has to be included in serverProps.
const serverProps = [ 'label', 'usesContext' ];
for ( const prop in existingSource ) {
if ( ! serverProps.includes( prop ) && existingSource[ prop ] ) {
Expand Down Expand Up @@ -892,12 +893,9 @@ export const registerBlockBindingsSource = ( source ) => {
warning( 'Block bindings source canUserEditValue must be a function.' );
return;
}

// Check the `getFieldsList` property is correct.
if ( getFieldsList && typeof getFieldsList !== 'function' ) {
// eslint-disable-next-line no-console
warning( 'Block bindings source getFieldsList must be a function.' );
return;
// Check the `fields` property is correct.
if ( args && typeof args !== 'object' ) {
warning( 'Block bindings source args must be an object.' );
}

return unlock( dispatch( blocksStore ) ).addBlockBindingsSource( source );
Expand Down
12 changes: 6 additions & 6 deletions packages/blocks/src/api/test/registration.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
getBlockType,
getBlockTypes,
getBlockSupport,
getBlockVariations,

Check failure on line 32 in packages/blocks/src/api/test/registration.js

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 22) 4/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["Block bindings source args must be an object."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at processTicksAndRejections (node:internal/process/task_queues:105:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)

Check failure on line 32 in packages/blocks/src/api/test/registration.js

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 20) 4/4

Error: expect(jest.fn()).not.toHaveWarned(expected) Expected mock function not to be called but it was called with: ["Block bindings source args must be an object."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.assertExpectedCalls (/home/runner/work/gutenberg/gutenberg/packages/jest-console/src/index.js:32:40) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusHook (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:280:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:253:5) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)
getBlockBindingsSource,
hasBlockSupport,
isReusableBlock,
Expand Down Expand Up @@ -1697,15 +1697,15 @@
expect( getBlockBindingsSource( 'core/testing' ) ).toBeUndefined();
} );

// Check the `getFieldsList` callback is correct.
it( 'should reject invalid getFieldsList callback', () => {
// Check the `args` callback is correct.
it( 'should reject invalid args callback', () => {
registerBlockBindingsSource( {
name: 'core/testing',
label: 'testing',
getFieldsList: 'should be a function',
args: 'should be a function',
} );
expect( console ).toHaveWarnedWith(

Check failure on line 1707 in packages/blocks/src/api/test/registration.js

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 22) 4/4

Error: expect(jest.fn()).toHaveWarnedWith(expected) Expected mock function to be called with: ["Block bindings source args must be a function."] but it was called with: ["Block bindings source args must be an object."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.toHaveWarnedWith (/home/runner/work/gutenberg/gutenberg/packages/blocks/src/api/test/registration.js:1707:22) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:315:40) at processTicksAndRejections (node:internal/process/task_queues:105:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:251:3) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)

Check failure on line 1707 in packages/blocks/src/api/test/registration.js

View workflow job for this annotation

GitHub Actions / JavaScript (Node.js 20) 4/4

Error: expect(jest.fn()).toHaveWarnedWith(expected) Expected mock function to be called with: ["Block bindings source args must be a function."] but it was called with: ["Block bindings source args must be an object."] console.warn() should not be used unless explicitly expected See https://www.npmjs.com/package/@wordpress/jest-console for details. at Object.toHaveWarnedWith (/home/runner/work/gutenberg/gutenberg/packages/blocks/src/api/test/registration.js:1707:22) at Promise.then.completed (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:300:28) at new Promise (<anonymous>) at callAsyncCircusFn (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/utils.js:233:10) at _callCircusTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:315:40) at processTicksAndRejections (node:internal/process/task_queues:95:5) at _runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:251:3) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:125:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at _runTestsForDescribeBlock (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:120:9) at run (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/run.js:70:3) at runAndTransformResultsToJestFormat (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapterInit.js:122:21) at jestAdapter (/home/runner/work/gutenberg/gutenberg/node_modules/jest-circus/build/legacy-code-todo-rewrite/jestAdapter.js:79:19) at runTestInternal (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:367:16) at runTest (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/runTest.js:444:34) at Object.worker (/home/runner/work/gutenberg/gutenberg/node_modules/jest-runner/build/testWorker.js:106:12)
'Block bindings source getFieldsList must be a function.'
'Block bindings source args must be a function.'
);
expect( getBlockBindingsSource( 'core/testing' ) ).toBeUndefined();
} );
Expand All @@ -1718,7 +1718,7 @@
getValues: () => 'value',
setValues: () => 'new values',
canUserEditValue: () => true,
getFieldsList: () => {
args: () => {
return { field: 'value' };
},
};
Expand All @@ -1742,7 +1742,7 @@
expect( source.getValues ).toBeUndefined();
expect( source.setValues ).toBeUndefined();
expect( source.canUserEditValue ).toBeUndefined();
expect( source.getFieldsList ).toBeUndefined();
expect( source.args ).toBeUndefined();
unregisterBlockBindingsSource( 'core/valid-source' );
} );

Expand Down
2 changes: 1 addition & 1 deletion packages/blocks/src/store/private-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function addBlockBindingsSource( source ) {
getValues: source.getValues,
setValues: source.setValues,
canUserEditValue: source.canUserEditValue,
getFieldsList: source.getFieldsList,
args: source.args,
};
}

Expand Down
8 changes: 4 additions & 4 deletions packages/blocks/src/store/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,11 @@ export function blockBindingsSources( state = {}, action ) {
switch ( action.type ) {
case 'ADD_BLOCK_BINDINGS_SOURCE':
// Only open this API in Gutenberg and for `core/post-meta` for the moment.
let getFieldsList;
let args;
if ( globalThis.IS_GUTENBERG_PLUGIN ) {
getFieldsList = action.getFieldsList;
args = action.args;
} else if ( action.name === 'core/post-meta' ) {
getFieldsList = action.getFieldsList;
args = action.args;
}
return {
...state,
Expand All @@ -413,7 +413,7 @@ export function blockBindingsSources( state = {}, action ) {
// Only set `canUserEditValue` if `setValues` is also defined.
canUserEditValue:
action.setValues && action.canUserEditValue,
getFieldsList,
args,
},
};
case 'REMOVE_BLOCK_BINDINGS_SOURCE':
Expand Down
2 changes: 1 addition & 1 deletion packages/e2e-tests/plugins/block-bindings/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ registerBlockBindingsSource( {
getValues,
setValues,
canUserEditValue: () => true,
getFieldsList: () => fieldsList,
fields: () => fieldsList,
} );

registerBlockBindingsSource( {
Expand Down
4 changes: 1 addition & 3 deletions packages/editor/src/bindings/post-meta.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,5 @@ export default {

return true;
},
getFieldsList( { select, context } ) {
return getPostMetaFields( select, context );
},
args: ( { select, context } ) => getPostMetaFields( select, context ),
};
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@
} );
} );

test.describe( 'getFieldsList', () => {
test.describe( 'fields', () => {
test( 'should be possible to update attribute value through bindings UI', async ( {
editor,
page,
Expand All @@ -781,7 +781,7 @@
await page
.getByRole( 'menuitemradio' )
.filter( { hasText: 'Text Field Label' } )
.click();

Check failure on line 784 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI

1) [chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 782 | .getByRole( 'menuitemradio' ) 783 | .filter( { hasText: 'Text Field Label' } ) > 784 | .click(); | ^ 785 | const paragraphBlock = editor.canvas.getByRole( 'document', { 786 | name: 'Block: Paragraph', 787 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:784:6

Check failure on line 784 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI

1) [chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 782 | .getByRole( 'menuitemradio' ) 783 | .filter( { hasText: 'Text Field Label' } ) > 784 | .click(); | ^ 785 | const paragraphBlock = editor.canvas.getByRole( 'document', { 786 | name: 'Block: Paragraph', 787 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:784:6

Check failure on line 784 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI

1) [chromium] › editor/various/block-bindings/custom-sources.spec.js:767:3 › Registered sources › fields › should be possible to update attribute value through bindings UI Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 782 | .getByRole( 'menuitemradio' ) 783 | .filter( { hasText: 'Text Field Label' } ) > 784 | .click(); | ^ 785 | const paragraphBlock = editor.canvas.getByRole( 'document', { 786 | name: 'Block: Paragraph', 787 | } ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:784:6
const paragraphBlock = editor.canvas.getByRole( 'document', {
name: 'Block: Paragraph',
} );
Expand Down Expand Up @@ -917,7 +917,7 @@
const textField = page
.getByRole( 'menuitemradio' )
.filter( { hasText: 'Text Field Label' } );
await expect( textField ).toBeVisible();

Check failure on line 920 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI

2) [chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 918 | .getByRole( 'menuitemradio' ) 919 | .filter( { hasText: 'Text Field Label' } ); > 920 | await expect( textField ).toBeVisible(); | ^ 921 | await expect( textField ).toBeChecked(); 922 | const urlField = page 923 | .getByRole( 'menuitemradio' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:920:30

Check failure on line 920 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI

2) [chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 918 | .getByRole( 'menuitemradio' ) 919 | .filter( { hasText: 'Text Field Label' } ); > 920 | await expect( textField ).toBeVisible(); | ^ 921 | await expect( textField ).toBeChecked(); 922 | const urlField = page 923 | .getByRole( 'menuitemradio' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:920:30

Check failure on line 920 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI

2) [chromium] › editor/various/block-bindings/custom-sources.spec.js:898:3 › Registered sources › fields › should show all the available fields in the dropdown UI Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toBeVisible() Locator: getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) Expected: visible Received: <element(s) not found> Call log: - expect.toBeVisible with timeout 5000ms - waiting for getByRole('menuitemradio').filter({ hasText: 'Text Field Label' }) 918 | .getByRole( 'menuitemradio' ) 919 | .filter( { hasText: 'Text Field Label' } ); > 920 | await expect( textField ).toBeVisible(); | ^ 921 | await expect( textField ).toBeChecked(); 922 | const urlField = page 923 | .getByRole( 'menuitemradio' ) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:920:30
await expect( textField ).toBeChecked();
const urlField = page
.getByRole( 'menuitemradio' )
Expand Down Expand Up @@ -946,7 +946,7 @@
const contentButton = page.getByRole( 'button', {
name: 'content',
} );
await expect( contentButton ).toContainText( 'Text Field Label' );

Check failure on line 949 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel

3) [chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel Error: Timed out 5000ms waiting for expect(locator).toContainText(expected) Locator: getByRole('button', { name: 'content' }) Expected string: "Text Field Label" Received string: "contentComplete Source" Call log: - expect.toContainText with timeout 5000ms - waiting for getByRole('button', { name: 'content' }) - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item caaaf--ab-ae-ab-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" 947 | name: 'content', 948 | } ); > 949 | await expect( contentButton ).toContainText( 'Text Field Label' ); | ^ 950 | } ); 951 | } ); 952 | at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:949:34

Check failure on line 949 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel

3) [chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toContainText(expected) Locator: getByRole('button', { name: 'content' }) Expected string: "Text Field Label" Received string: "contentComplete Source" Call log: - expect.toContainText with timeout 5000ms - waiting for getByRole('button', { name: 'content' }) - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item cbfc-e-f-b-dbecce-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" 947 | name: 'content', 948 | } ); > 949 | await expect( contentButton ).toContainText( 'Text Field Label' ); | ^ 950 | } ); 951 | } ); 952 | at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:949:34

Check failure on line 949 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel

3) [chromium] › editor/various/block-bindings/custom-sources.spec.js:928:3 › Registered sources › fields › should show the connected fields in the attributes panel Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: Timed out 5000ms waiting for expect(locator).toContainText(expected) Locator: getByRole('button', { name: 'content' }) Expected string: "Text Field Label" Received string: "contentComplete Source" Call log: - expect.toContainText with timeout 5000ms - waiting for getByRole('button', { name: 'content' }) - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" - locator resolved to <button id=":r1l:" type="button" data-wp-c16t="true" aria-haspopup="menu" aria-expanded="false" data-wp-component="Item" class="components-item aed-b-a-df-ebbc-1e0ti6b e19lxcc00">…</button> - unexpected value "contentComplete Source" 947 | name: 'content', 948 | } ); > 949 | await expect( contentButton ).toContainText( 'Text Field Label' ); | ^ 950 | } ); 951 | } ); 952 | at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:949:34
} );
} );

Expand Down Expand Up @@ -1097,12 +1097,12 @@
await expect( paragraphBlock ).toBeEmpty();

const placeholder = paragraphBlock.locator( 'span' );
await expect( placeholder ).toHaveAttribute(

Check failure on line 1100 in test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 3

[chromium] › editor/various/block-bindings/custom-sources.spec.js:1074:3 › Registered sources › RichText workflows › should show placeholder prompt when value is empty and can edit

4) [chromium] › editor/various/block-bindings/custom-sources.spec.js:1074:3 › Registered sources › RichText workflows › should show placeholder prompt when value is empty and can edit Error: Timed out 5000ms waiting for expect(locator).toHaveAttribute(expected) Locator: locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Empty empty_field; start writing to edit its value' }).locator('span') Expected string: "Add Empty Field Label" Received string: "Add Complete Source" Call log: - expect.toHaveAttribute with timeout 5000ms - waiting for locator('[name="editor-canvas"]').contentFrame().getByRole('document', { name: 'Empty empty_field; start writing to edit its value' }).locator('span') - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" - locator resolved to <span data-rich-text-placeholder="Add Complete Source"></span> - unexpected value "Add Complete Source" 1098 | 1099 | const placeholder = paragraphBlock.locator( 'span' ); > 1100 | await expect( placeholder ).toHaveAttribute( | ^ 1101 | 'data-rich-text-placeholder', 1102 | 'Add Empty Field Label' 1103 | ); at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-bindings/custom-sources.spec.js:1100:32
'data-rich-text-placeholder',
'Add Empty Field Label'
);
} );
test( 'should show source label when value is empty, cannot edit, and `getFieldsList` is undefined', async ( {
test( 'should show source label when value is empty, cannot edit, and `fields` is undefined', async ( {
editor,
} ) => {
await editor.insertBlock( {
Expand Down
Loading