-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Blocks: Stabilise role
attribute property
#65484
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
06f70a3
Update usages
getdave f3c53dc
Update related functions
getdave a9d3779
Remove unwanted alias
getdave 9ce41a3
Properly deprecate the experimental method
getdave 94a4734
Deprecate and ensure backwards compatibility
getdave 8b6bab0
Make selector private
getdave c99343f
Ensure serializer works backwards compat
getdave 079d4ca
Ensure experiment API method still exposed on blocks package
getdave 12c8991
Add hint for updating role attribute
getdave 1e227a8
Remove unlock
getdave 9b1b4de
Improve readability of proxying
getdave 8ae6ad4
Add hint to serializer
getdave 710da14
use stabilised selector for the content role for edit mode
draganescu 37a0014
Attempt locking to fix unit test
getdave 3a4e596
Ensure mock returns correct value
getdave 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
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
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
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 |
---|---|---|
|
@@ -16,6 +16,7 @@ import { select, dispatch } from '@wordpress/data'; | |
import * as selectors from '../selectors'; | ||
import { store } from '../'; | ||
import { sectionRootClientIdKey } from '../private-keys'; | ||
import { lock } from '../../lock-unlock'; | ||
|
||
const { | ||
getBlockName, | ||
|
@@ -4475,14 +4476,14 @@ describe( 'getBlockEditingMode', () => { | |
}, | ||
}; | ||
|
||
const __experimentalHasContentRoleAttribute = jest.fn( ( name ) => { | ||
// consider paragraphs as content blocks. | ||
return name === 'core/p'; | ||
} ); | ||
const hasContentRoleAttribute = jest.fn( () => false ); | ||
|
||
const fauxPrivateAPIs = {}; | ||
|
||
lock( fauxPrivateAPIs, { hasContentRoleAttribute } ); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a correct mock to me. |
||
|
||
getBlockEditingMode.registry = { | ||
select: jest.fn( () => ( { | ||
__experimentalHasContentRoleAttribute, | ||
} ) ), | ||
select: jest.fn( () => fauxPrivateAPIs ), | ||
}; | ||
|
||
it( 'should return default by default', () => { | ||
|
@@ -4586,7 +4587,7 @@ describe( 'getBlockEditingMode', () => { | |
}, | ||
}, | ||
}; | ||
__experimentalHasContentRoleAttribute.mockReturnValueOnce( false ); | ||
hasContentRoleAttribute.mockReturnValueOnce( false ); | ||
expect( | ||
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' ) | ||
).toBe( 'disabled' ); | ||
|
@@ -4602,7 +4603,7 @@ describe( 'getBlockEditingMode', () => { | |
}, | ||
}, | ||
}; | ||
__experimentalHasContentRoleAttribute.mockReturnValueOnce( true ); | ||
hasContentRoleAttribute.mockReturnValueOnce( true ); | ||
expect( | ||
getBlockEditingMode( state, 'b3247f75-fd94-4fef-97f9-5bfd162cc416' ) | ||
).toBe( 'contentOnly' ); | ||
|
@@ -4642,12 +4643,15 @@ describe( 'getBlockEditingMode', () => { | |
} ); | ||
|
||
it( 'in navigation mode, blocks with content attributes within sections are contentOnly', () => { | ||
hasContentRoleAttribute.mockReturnValueOnce( true ); | ||
expect( | ||
getBlockEditingMode( | ||
navigationModeStateWithRootSection, | ||
'b3247f75-fd94-4fef-97f9-5bfd162cc416' | ||
) | ||
).toBe( 'contentOnly' ); | ||
|
||
hasContentRoleAttribute.mockReturnValueOnce( true ); | ||
Comment on lines
4645
to
+4654
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this test needs to include a test case that asserts the inverse cases. What do you think? |
||
expect( | ||
getBlockEditingMode( | ||
navigationModeStateWithRootSection, | ||
|
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
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
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
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
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.
Should these tests be moved to
selectors
tests now?