-
Notifications
You must be signed in to change notification settings - Fork 2k
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
E2E: Try to stabilize Atomic likes (again) #76414
Conversation
.frameLocator( `iframe[name^="like-comment-frame"]:below(:text("${ comment }"))` ) | ||
.first(); | ||
const commentContent = this.page.locator( '.comment-content', { hasText: comment } ); | ||
const likeButtonFrame = commentContent.frameLocator( "iframe[name^='like-comment-frame']" ); |
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.
Just using some modern syntax here, not a crucial change.
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 had an experimental branch where I made a similar change, so I can vouch it works.
@@ -38,7 +38,7 @@ describe( 'Likes: Comment', function () { | |||
let commentToBeUnliked: NewCommentResponse; | |||
let restAPIClient: RestAPIClient; | |||
|
|||
beforeAll( async function () { | |||
it( 'Setup the test', async function () { |
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.
Changed it to it
because the title gives a bit more info immediately when looking at the error in CI.
This PR does not affect the size of JS and CSS bundles shipped to the user's browser. Generated by performance advisor bot at iscalypsofastyet.com. |
@worldomonation I think there's something wrong with the comment /cc @fullofcaffeine Edit: I was right 😄 This is what the like response looks like after a few retries: First try: {
error: 'unknown_comment',
message: 'Unknown comment'
} A few retries later. Notice how the comment is seemingly liked ( {
success: true,
i_like: true,
like_count: 0,
} A couple more retries later, finally, a correct response. The comment is liked by us, and the count is now correctly at 1. 😌 {
success: true,
i_like: true,
like_count: 1,
} This is quite a doozy to me. You can clearly see the payload inconsistency now. Possibly worth reporting to the AT team? Another edit: So the interesting part right now is that the response can get stuck at |
// The comment takes some time to settle. If we request the like | ||
// immediately we might be getting the `unknown_comment` error. Let's do | ||
// a few retries to make sure the like is getting through. | ||
const likeRetryCount = 10; |
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.
comment:non-blocking - I have a WIP branch locally to try to stabilize this test as well, and I tried to extract the retry mechanism to ElementHelper
and ran into difficulties generalizing the parameter definition and forgot to ask @dpasque whether generics would help with the scenario.
What I had was the following:
// In the test itself
if ( envVariables.TEST_ON_ATOMIC ) {
ElementHelper.retryRequest(
restAPIClient.getComment(
testAccount.credentials.testSites?.primary.id as number,
commentToBeLiked.ID
)
);
}
// in ElementHelper
export async function retryRequest< T, P >(
func: () => Promise< void >,
parameters: [ P ],
{ timeout = 5000 }: { timeout?: number } = {}
): Promise< void > {
for ( let retries = 3; retries > 0; retries -= 1 ) {
try {
return await func( ...parameters );
} catch ( err ) {
// Throw the error if final retry failed.
if ( retries === 1 ) {
throw err;
} else {
await new Promise( ( resolve ) => setTimeout( resolve, timeout ) );
}
}
}
return;
}
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.
If we only need the retry logic in one place, I don't think we don't need to worry about turning it into a helper. Is there any other place that it'd currently be useful?
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'd even say that this should generally not be encouraged, so I'd actually avoid creating a helper for it. We need this here because of a faulty app logic which, ultimately, should be addressed somewhere else.
This is definitely strange. Previously I've filed #75952 for the first situation you've covered, where the comment is posted but the API returns a 404 when attempting to access the comment. I did waffle a bit on whether to expand the scope of #75952 to cover the later two situations you've mentioned, but have elected to file a new issue to cover the situation for Filed #76444. |
I've left a message in the AT channel, but not sure if it's the right place. p1682922721277819-slack-C7YPW6K40 |
Related: #75947
Proposed Changes
When adding a comment on an Atomic site, it takes a bit until that comment is settled. Sometimes, when we send the like request immediately after creating a comment, we get an
unknown_comment
error response. To address that, let's make a couplelike
request retries before failing the test.Testing Instructions