Fix autosave controller tests#10980
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
d05a310 to
fade2c7
Compare
| * When real-time collaboration is enabled, autosaving a draft post by the | ||
| * same author should create a revision instead of updating the post directly. | ||
| */ | ||
| public function test_rest_autosave_draft_post_same_author_with_rtc() { |
There was a problem hiding this comment.
Add @ticket annotation.
mukeshpanchal27
left a comment
There was a problem hiding this comment.
Let's remove original state as we don't need that one to manage
| } | ||
|
|
||
| public function test_rest_autosave_draft_post_same_author() { | ||
| $original_option = get_option( 'enable_real_time_collaboration' ); |
There was a problem hiding this comment.
| $original_option = get_option( 'enable_real_time_collaboration' ); |
| $this->assertSame( $post_data['post_excerpt'], $post->post_excerpt ); | ||
|
|
||
| wp_delete_post( $post_id ); | ||
| update_option( 'enable_real_time_collaboration', $original_option ); |
There was a problem hiding this comment.
| update_option( 'enable_real_time_collaboration', $original_option ); |
| } | ||
|
|
||
| public function test_update_item_draft_page_with_parent() { | ||
| $original_option = get_option( 'enable_real_time_collaboration' ); |
There was a problem hiding this comment.
| $original_option = get_option( 'enable_real_time_collaboration' ); |
|
|
||
| $this->assertSame( self::$child_draft_page_id, $data['id'] ); | ||
| $this->assertSame( self::$parent_page_id, $data['parent'] ); | ||
| update_option( 'enable_real_time_collaboration', $original_option ); |
There was a problem hiding this comment.
| update_option( 'enable_real_time_collaboration', $original_option ); |
|
|
||
| public function test_rest_autosave_draft_post_same_author() { | ||
| $original_option = get_option( 'enable_real_time_collaboration' ); | ||
| update_option( 'enable_real_time_collaboration', false ); |
There was a problem hiding this comment.
Add one line comment why we added this ☝️
| "wp-block-editor/v1", | ||
| "wp-abilities/v1" | ||
| "wp-abilities/v1", | ||
| "wp-sync/v1" |
There was a problem hiding this comment.
Are this changes wp-sync/v1 newly apply here?
There was a problem hiding this comment.
Yes, after real-time collaboration was enabled by default, this endpoint is registered and must be added to the fixture.
Fix autosave controller tests, which began failing when RTC was changed to enabled by default. The tests now need to cover two different code paths:
wordpress-develop/src/wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
Line 259 in 15ffb43
Trac ticket: https://core.trac.wordpress.org/ticket/64622
Use of AI Tools
Partially generated by Claude Code