Skip to content

Fix autosave controller tests#10980

Closed
chriszarate wants to merge 2 commits intoWordPress:trunkfrom
chriszarate:fix/rtc-autosave-tests
Closed

Fix autosave controller tests#10980
chriszarate wants to merge 2 commits intoWordPress:trunkfrom
chriszarate:fix/rtc-autosave-tests

Conversation

@chriszarate
Copy link

@chriszarate chriszarate commented Feb 19, 2026

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:

if ( $is_draft && (int) $post->post_author === $user_id && ! $post_lock && ! $is_collaboration_enabled ) {

Trac ticket: https://core.trac.wordpress.org/ticket/64622

Use of AI Tools

Partially generated by Claude Code

@github-actions
Copy link

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props czarate.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@chriszarate chriszarate force-pushed the fix/rtc-autosave-tests branch from d05a310 to fade2c7 Compare February 19, 2026 14:39
* 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() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add @ticket annotation.

Copy link
Member

@mukeshpanchal27 mukeshpanchal27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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' );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
$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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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 );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add one line comment why we added this ☝️

"wp-block-editor/v1",
"wp-abilities/v1"
"wp-abilities/v1",
"wp-sync/v1"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are this changes wp-sync/v1 newly apply here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, after real-time collaboration was enabled by default, this endpoint is registered and must be added to the fixture.

@github-actions
Copy link

A commit was made that fixes the Trac ticket referenced in the description of this pull request.

SVN changeset: 61702
GitHub commit: 702af38

This PR will be closed, but please confirm the accuracy of this and reopen if there is more work to be done.

@github-actions github-actions bot closed this Feb 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants