-
Notifications
You must be signed in to change notification settings - Fork 800
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
Social: Fix connection_test_result call merging issue #38367
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks appearing at the bottom of this PR are passing or skipped. |
@@ -13,7 +13,7 @@ import { | |||
const connections = connectionsList.map( connection => ( { ...connection, enabled: true } ) ); | |||
|
|||
const post = { | |||
jetpack_publicize_connections: [ connections[ 0 ] ], | |||
jetpack_publicize_connections: [ connections ], |
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.
cc @manzoorwanijk because you wrote this testcase:
I think this change won't alter the testing power of this test, I also think that it should never be the case that prevConnections is not the same length as freshConnections
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.
Shouldn't it then be this instead?
jetpack_publicize_connections: [ connections ], | |
jetpack_publicize_connections: connections, |
// A connection was added after the test call started, so we need to add it to the list. | ||
if ( prevConnections.length > freshConnections.length ) { | ||
const addedConnection = prevConnections.find( | ||
conn => | ||
! freshConnections.some( freshConn => | ||
freshConn.connection_id | ||
? freshConn.connection_id === conn.connection_id | ||
: freshConn.id === conn.id | ||
) | ||
); | ||
|
||
if ( addedConnection ) { | ||
connections.push( addedConnection ); | ||
} | ||
} | ||
|
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 approach is problematic. Currently, if a post has connections saved in post meta (jetpack_publicize_connections
), it's possible that the list is outdated and any of those connections would have been removed from connections management. Thus, connection test result resets the list and ensures that only the active connections are in the list.
With this change, it will add those removed connections back to the list which is not what we want.
Steps:
- Add some connections
- Create a post and publish or save it as draft.
- Goto Social or Jetpack settings page and remove one or more connections
- Go back to the post editor
- On
trunk,
the removed connections should not be retained after test results, but with this change, they are retained.
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 needs a rethink. Please see the comments above.
Closing in favour on other solution in a clean PR - #38408 |
Fixes https://github.com/Automattic/jetpack-reach/issues/448
On slower connections there is a scenario which could happen that messes up the connection state:
test_connections
call fires, but takes 10-15 seconds to completetest_connections
call will mess up the state when it finishes, it will either remove the new connection from the UI, or add back the removed one.If you have a speedy network it's harder to reproduce, so one solution for that is to make changes in the
mergeConnections
function in theprojects/js-packages/publicize-components/src/social-store/actions/connection-data.js
file, make the inner function async, and add the await line at the start like so:Issue presented with connection removal - the connection gets added back after
test_connections
finishes:CleanShot.2024-07-17.at.14.20.50.png.mp4
Issue presented with the connection addition - the connection gets removed after
test_connections
finishes:CleanShot.2024-07-17.at.14.23.01.png.mp4
Proposed changes:
prevConnections
andfreshConnections
is not the sameOther information:
Jetpack product discussion
Does this pull request change what data or activity we track or use?
Testing instructions: