-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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: Refactor e2e tests #65526
Merged
cbravobernal
merged 27 commits into
trunk
from
update/reorganize-block-bindings-e2e-tests
Sep 27, 2024
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
99cd7ec
WIP: Add script to block bindings tests
SantosGuillamot 3986ff9
Add first version of block bindings test theme
SantosGuillamot 3831c97
Register movie CPT
SantosGuillamot 5941ef4
Create structure for tests
SantosGuillamot fcdcdc6
Remove current specs
SantosGuillamot 9a67274
Share data between server and client
SantosGuillamot 53b6ddd
Add `getValues` tests
SantosGuillamot b15c9bb
Move checks for paragraph locking
SantosGuillamot 4f9ba94
Wrap tests that should lock editing
SantosGuillamot 4d36f2a
Add setValues e2e tests
SantosGuillamot 968d80e
Add tests for `getFieldsList`
SantosGuillamot d6105fd
Add tests for rich text workflows
SantosGuillamot fdab66f
Add remaining use cases
SantosGuillamot 9e1c846
Use one complete source
SantosGuillamot 041fe6c
Add tests for CPT template
SantosGuillamot 7722cf9
Fix label test
SantosGuillamot 969be9d
Add attributes panel tests
SantosGuillamot 82dd071
Add dropdown post meta tests
SantosGuillamot b40ea0c
Add post meta tests for custom templates
SantosGuillamot 74b3200
Add e2e tests in movie post
SantosGuillamot 31d7b34
Add template for posts
SantosGuillamot 34766ec
Rename specs
SantosGuillamot 5b0895c
Fix post-meta tests
SantosGuillamot 60ada8f
Check post meta in the frontend
SantosGuillamot c7457d0
Update theme definition
SantosGuillamot 6ed6f43
Populate `setValues`
SantosGuillamot 5b4f1e3
Check image title locking
SantosGuillamot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
const { unlock } = | ||
wp.privateApis.__dangerousOptInToUnstableAPIsOnlyForCoreModules( | ||
'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', | ||
'@wordpress/blocks' | ||
); | ||
|
||
const { registerBlockBindingsSource } = unlock( wp.blocks.privateApis ); | ||
const { fieldsList } = window.testingBindings || {}; | ||
|
||
const getValues = ( { bindings } ) => { | ||
const newValues = {}; | ||
for ( const [ attributeName, source ] of Object.entries( bindings ) ) { | ||
newValues[ attributeName ] = fieldsList[ source.args.key ]?.value; | ||
} | ||
return newValues; | ||
}; | ||
const setValues = ( { registry, bindings } ) => { | ||
Object.values( bindings ).forEach( ( { args, newValue } ) => { | ||
// Example of what could be done. | ||
registry.dispatch( 'core' ).editEntityRecord( 'postType', 'post', 1, { | ||
meta: { [ args?.key ]: newValue }, | ||
} ); | ||
} ); | ||
}; | ||
|
||
registerBlockBindingsSource( { | ||
name: 'testing/complete-source', | ||
label: 'Complete Source', | ||
getValues, | ||
setValues, | ||
canUserEditValue: () => true, | ||
getFieldsList: () => fieldsList, | ||
} ); | ||
|
||
registerBlockBindingsSource( { | ||
name: 'testing/can-user-edit-false', | ||
label: 'Can User Edit: False', | ||
getValues, | ||
setValues, | ||
canUserEditValue: () => false, | ||
} ); | ||
|
||
registerBlockBindingsSource( { | ||
name: 'testing/can-user-edit-undefined', | ||
label: 'Can User Edit: Undefined', | ||
getValues, | ||
setValues, | ||
} ); | ||
|
||
registerBlockBindingsSource( { | ||
name: 'testing/set-values-undefined', | ||
label: 'Set Values: Undefined', | ||
getValues, | ||
canUserEditValue: () => true, | ||
} ); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remember to update this once they are public.