Repository navigation
RTC: Disable multiple collaborators if meta boxes are present #75939
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f9d8a9e
Disable RTC when metaboxes are in use
ingeniumed 56fb5bd
Fix merge conflicts
ingeniumed 8385095
Use Collaboration supported, and ensure the manager is left alone
ingeniumed 77891d8
Add an e2e test
ingeniumed 578019a
Fix the types
ingeniumed 2fd63e8
CR
ingeniumed d10bbd5
Add a doc for the private action
ingeniumed e5adcfd
Remove extra line
ingeniumed 4a4afa9
Clean up
chriszarate 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
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
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
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
106 changes: 106 additions & 0 deletions
106
test/e2e/specs/editor/collaboration/collaboration-metabox-lock.spec.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { test, expect } from './fixtures'; | ||
| import { SECOND_USER } from './fixtures/collaboration-utils'; | ||
|
|
||
| const BASE_URL = process.env.WP_BASE_URL || 'http://localhost:8889'; | ||
|
|
||
| test.describe( 'Collaboration with meta boxes', () => { | ||
| test.beforeAll( async ( { requestUtils } ) => { | ||
| await requestUtils.activatePlugin( 'gutenberg-test-plugin-meta-box' ); | ||
| } ); | ||
|
|
||
| test.afterAll( async ( { requestUtils } ) => { | ||
| await requestUtils.deactivatePlugin( 'gutenberg-test-plugin-meta-box' ); | ||
| } ); | ||
|
|
||
| test( 'shows post-locked modal when meta boxes disable collaboration', async ( { | ||
| collaborationUtils, | ||
| requestUtils, | ||
| admin, | ||
| editor, | ||
| page, | ||
| } ) => { | ||
| // Ensure collaboration is enabled (the fixture enables it, but | ||
| // be explicit to match the pattern of other collaboration tests). | ||
| await collaborationUtils.setCollaboration( true ); | ||
|
|
||
| // Create a draft post. | ||
| const post = await requestUtils.createPost( { | ||
| title: 'Meta Box Lock Test', | ||
| status: 'draft', | ||
| date_gmt: new Date().toISOString(), | ||
| } ); | ||
|
|
||
| // User 1 (admin) opens the post. | ||
| await admin.visitAdminPage( | ||
| 'post.php', | ||
| `post=${ post.id }&action=edit` | ||
| ); | ||
| await editor.setPreferences( 'core/edit-post', { | ||
| welcomeGuide: false, | ||
| fullscreenMode: false, | ||
| } ); | ||
|
|
||
| // Wait for meta boxes to initialize and disable collaboration. | ||
| // collaborationSupported starts as true, then the meta box hook | ||
| // sets it to false once meta boxes are detected. | ||
| await page.waitForFunction( | ||
| () => | ||
| window?.wp?.data | ||
| ?.select( 'core/editor' ) | ||
| ?.isCollaborationEnabledForCurrentPost?.() === false, | ||
| { timeout: 15000 } | ||
| ); | ||
|
|
||
| // Set up second browser context for User 2. | ||
| const secondContext = await admin.browser.newContext( { | ||
| baseURL: BASE_URL, | ||
| } ); | ||
| const page2 = await secondContext.newPage(); | ||
|
|
||
| try { | ||
| // Log in the second user. | ||
| await page2.goto( '/wp-login.php' ); | ||
| await page2.locator( '#user_login' ).fill( SECOND_USER.username ); | ||
| await page2.locator( '#user_pass' ).fill( SECOND_USER.password ); | ||
| await page2.getByRole( 'button', { name: 'Log In' } ).click(); | ||
| await page2.waitForURL( '**/wp-admin/**' ); | ||
|
|
||
| // User 2 navigates to the same post. | ||
| await page2.goto( | ||
| `/wp-admin/post.php?post=${ post.id }&action=edit` | ||
| ); | ||
|
|
||
| // Wait for wp.data to be available on User 2's page. | ||
| await page2.waitForFunction( | ||
| () => window?.wp?.data && window?.wp?.blocks, | ||
| { timeout: 15000 } | ||
| ); | ||
|
|
||
| // Assert the post-locked modal appears. | ||
| // Because collaboration is disabled (meta boxes), WordPress | ||
| // falls back to standard post-locking. User 2 sees the | ||
| // "This post is already being edited" modal. | ||
| const modal = page2.getByRole( 'dialog', { | ||
| name: 'This post is already being edited', | ||
| } ); | ||
| await expect( modal ).toBeVisible( { timeout: 15000 } ); | ||
|
|
||
| // Assert the explanation about meta box incompatibility. | ||
| await expect( | ||
| modal.getByText( | ||
| 'Because this post uses plugins that aren\u2019t compatible with real-time collaboration, only one person can edit at a time.' | ||
| ) | ||
| ).toBeVisible(); | ||
|
|
||
| // Assert the "Take over" option is available. | ||
| await expect( | ||
| modal.getByRole( 'link', { name: 'Take over' } ) | ||
| ).toBeVisible(); | ||
| } finally { | ||
| await secondContext.close(); | ||
| } | ||
| } ); | ||
| } ); |
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.
Is this
ifcheck necessary? What's the downside of always callingsetCollaborationSupported( false )?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.
I experimented with that on the previous PR. This is a catch-22 situation.
By default,
collaborationSupportedis set to true. This means that whenreal-time collaborationis disabled the RTC specific text in the post locked modal won't be disabled. WhencollaborationSupportedis set to false, the RTC specific text in the post locked modal is shown.So by having the
isCollaborationEnabledin place, it ensures thatcollaborationSupportedisn't flipped unless unlessreal-time collaborationis enabled.isCollaborationEnabled-> is the setting enabled?collaborationSupported-> is collaboration supported? Doesn't talk about it being enabled or disabledI'm open to a better solution on how to improve this. I couldn't really find one that wouldn't trigger a whole circular dependency problem.