-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Annotations: Add end-to-end tests for annotations API #12186
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,9 @@ | |
var registerPlugin = wp.plugins.registerPlugin; | ||
var PluginSidebar = wp.editPost.PluginSidebar; | ||
var PluginSidebarMoreMenuItem = wp.editPost.PluginSidebarMoreMenuItem; | ||
var applyFormat = wp.richText.applyFormat; | ||
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.
|
||
var registerFormatType = wp.richText.registerFormatType; | ||
var domReady = wp.domReady; | ||
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.
|
||
|
||
class SidebarContents extends Component { | ||
constructor( props ) { | ||
|
@@ -118,4 +121,38 @@ | |
icon: 'text', | ||
render: AnnotationsSidebar | ||
} ); | ||
|
||
window.annotationsCountingRerenders = 0; | ||
const props = {}; | ||
|
||
const FORMAT_NAME = 'rerender/counter'; | ||
|
||
function countRerender( formats, text ) { | ||
if ( text.startsWith( 'RerenderCounter' ) ) { | ||
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. Can't we create a separate format type for these tests? 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. Assuming it is already separate because it's called |
||
window.annotationsCountingRerenders++; | ||
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. It's strange to me that this is being set in a separate file. I have no idea from looking at the other file where it's coming from. Maybe better to more this registration to the test cases? |
||
} | ||
|
||
return formats; | ||
} | ||
|
||
domReady( () => { | ||
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. Why is a format being registered when the DOM is ready? What does the DOM have to do with this? |
||
registerFormatType( FORMAT_NAME, { | ||
name: FORMAT_NAME, | ||
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 attribute is not needed? |
||
title: __( 'Rerender counter' ), | ||
tagName: 'mark', | ||
className: 'annotations-rerender-counter', | ||
attributes: { | ||
className: 'class', | ||
}, | ||
edit: () => { | ||
return null; | ||
}, | ||
__experimentalCreatePrepareEditableTree: () => { | ||
return countRerender; | ||
}, | ||
__experimentalGetPropsForEditableTreePreparation: () => { | ||
return props; | ||
} | ||
} ); | ||
} ) | ||
} )(); |
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.
This can be written as
toBe
.