-
Notifications
You must be signed in to change notification settings - Fork 6
Fix: Hidden post-edit tabs still refresh the post-lock presence entry #78
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
Open
Intenzi
wants to merge
2
commits into
WordPress:main
Choose a base branch
from
Intenzi:fix/hidden-post-lock-updates
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+28
−23
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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 hidden or 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 hidden or 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.
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.
Might be worth adding a positive assertion on the visible side too, so a regression that always deletes the key doesn't slip through:
Uh oh!
There was an error while loading. Please reload this page.
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.
Hi @josephfusco, I'd love your input on the implementation direction here.
I went through with implementing the positive assertion and it has lead to a blocker.
After applying the positive assertion, the test was consistently failing when I ran the e2e tests locally.
Upon digging deeper into how Core handles post locking, I realised that the current negative assertion implementation done by me is also a false positive.
In Core's
post.js,wp-refresh-post-lockis only attached if#post-lock-dialogexists in the DOM:In standard Core PHP (
_admin_notice_post_locked()), Core only outputs#post-lock-dialoginto the HTML if there is an active lock conflict from another user. The another user check is performed insidewp_check_post_lock:-For a single user editing a post alone, Core never outputs that div, so
post.jsskips attachingwp-refresh-post-lockaltogether.Because of this, the test was passing the negative assertion simply because Core never attached the key in the first place, not because our visibility handler stripped it.
Proposed Fix:
We can implement a separate test to use a genuine multi-user flow using Playwright's
browser.newContext()to simulate two actual users (User A & User B):User B opens the post first in Context 1 to acquire the lock.
User A opens the post second in Context 2, which triggers Core's multi-user lock dialog naturally.
Then we perform visibility, detached from visibility tests on it.
Alternatively, we could simulate the lock conflict state by updating
_edit_lockmeta prior to page load if we want a single-browser run.Which approach would you prefer for the test suite?
Uh oh!
There was an error while loading. Please reload this page.
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.
Great catch, you're right that the negative assertion was always true. I'd maybe lean towards the
browser.newContext()approach. Have User B navigate to the post edit page first to naturally acquire the lock, then User A opens the same post and the lock dialog is present. Run the visibility assertions from there. That's the most authentic test of the behavior.